PHP Array into string [B] Array & nbsp; (& nbsp; [0] & nbsp; & gt; & nbsp; 0 & nbsp; [1] & nbsp; & gt; & nbsp; 1 [2] & gt; 1) how to convert an array into an array (, 1) or an array (a1, 0) [B] hope everyone can help ------ solution ------------------- convert the PHP array to a string
[B] Array ([0] => 0 [1] => 1 [2] => 1)How can this array be converted to array (, 1)
Or how to convert a =, 0 to array (, 0) [/B]
------ Solution ----------------------
Array ([0] => 0 [1] => 1 [2] => 1), that is, array (, 1), but it is printed out, the key name (subscript) is automatically added, which starts from 0 by default.
The second question is, do you want to do this?
$a='1,1,0';
$new=explode(',',$a);
echo "";
print_r($new);
echo "
";
/*
Array
(
[0] => 1
[1] => 1
[2] => 0
)
*/
------ Solution ----------------------
PHP array conversion string
// Use The explode () function to convert a string to an array.
$ Str = "PHP, JSP, ASP"; // defines a string
$ Strs = explode (",", $ str); // Use The explode () function to convert a string to an array.
Print_r ($ strs); // output array element
?>
// Assign values directly to array elements
$ Array [1] = "";
$ Array [2] = "li ";
$ Array [3] = "ba ";
$ Array [4] = "ba ";
Print_r ($ array); // outputs the structure of the created array
?>
------ Solution ----------------------
Array_values ($ arr );
------ Solution ----------------------
String, 0 needs to be saved to the array by number and explode ()
If you need a method to store arrays with strings/files, use serialize () and unserialize ()