Array is the pattern, and the disk array pattern is to combine the storage space of several disks to form a large single contiguous storage space. Array () is actually a language structure (language construct), usually used to define a direct array, but its usage is very similar to the use of functions, so you need to use more information about array array can check related manuals, this article we share with you two of tips.
1,the PHP object to the array method ( object to array):
/**
* Object to Array
*/
function Object_to_array ($obj) {
$_arr=is_object ($obj)? Get_object_vars ($obj): $obj;
foreach ($_arr as $key = = $val) {
$val = (Is_array ($val)) | | Is_object ($val)? Object_to_array ($val): $val;
$arr [$key]= $val;
}
return $arr;
}
2,PHP json character to the array method (JSON to array):
If it is a JSON string, you can convert the string to an array directly from the Json_decode function.
Json_decode (PHP 5 >= 5.2.0, PECL json >= 1.2.0)
Json_decode-accepts a JSON-formatted string and converts it to a PHP variable
Mixed Json_decode (String $json [, bool $assoc])
Parameters:
JSON string in JSON string format to decode.
Assoc When this argument is TRUE, returns the result of an array (associative array), which defaults to false and returns an object.