Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6742287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:49:32+00:00 2026-05-26T11:49:32+00:00

I need to do an import of an array of checkboxes, but there is

  • 0

I need to do an import of an array of checkboxes, but there is a value that I don’t how it is determined.

The array is based on a user meta option that I created that shows a list of category checkbox options. It grabs all of the categories and creates a checkbox option that can be saved to a user’s profile. The categories have different levels (parent, child, or child-child).

This is part of the coding I used to create the user meta option:

$args = array( 'hide_empty' => 0, 'taxonomy'=> 'category');
$categories =  get_categories($args);

if ($categories){
                        foreach ( $categories as $category ){ 
                            if(in_array($category->term_id,(array)$data)) {
                                $selected = 'checked="checked""';
                            } else {
                                $selected = '';
                            }
                            echo '<input name="user_cats[]" value="'.$category->term_id.'" '.$selected.' type="checkbox"/> '.$category->name.'<br/>';
                        }
                    }

After doing a test save of the some of the checkbox options, I examined the database value of the “user_cats” field, it gives me something like this:

a:2:{i:0;s:2:”20″;i:1;s:3:”343″;}

Now, I know what all but one of the variables stand for.

a = Total amount (quantity) of values/selections

i = Sequential number of the value/selection (*Starting with 0)

“X” = The number value within the parenthesis is the value

My question is, what is the s: value based on? The reason I ask is because Im compiling a csv file of 1,300 records to import and I dont know how the s: values are determined. I tried just give s: a constant value of 2, but after importing the values the options were not selected based on the arrays that were imported. That didn’t work.

So I have a feeling that the selecting of the correct options are based on the s: value. An alternative would be if Im able to import an array without that current syntax.

I spent a long time manually compiling the file with excel functions and tricks and this is the only road block. Any help with this would be a major savior.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:49:33+00:00Added an answer on May 26, 2026 at 11:49 am

    That’s the php serialize format:

    a:2 - array with 2 elements
    s:2 - string 2 characters long
    i:0 - integer with value "0"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created my array in a method and some variables that need to be
In our project we need to import the csv file to postgres. There are
I've got some csv-files that I need to import to our system using php.
I need a ruby equivalent for the following python code import array my_array =
with: import numpy as np array = get_array() I need to do the following
I need to convert a StringBuffer Array to String Array for sorting. Is there
I need to find if a numpy array is inside other numpy array, but
I have a string-array, that i need to display in a layout. The code
App::import('model','User'); $user_model = new User(); $xxx = $user_model->find(all, array(fields=>array(User.yyy))); $zzz = $user_model->find(count, array(fields =>
I have a 2D masked array of values that I need to sort from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.