php tutorial save two-dimensional array to one-dimensional array tutorial
$array = array(
array(1,2),
array(3,4),
array('www .bkjia.com','php100.com')
);
//See the above two-dimensional number structure, let’s use foreach to example
function array_2to1( $array)
{
static $result_array=array();
foreach($array as $value)
{
if(is_array($value))
{
arrau_2to1($value);
} }
else
🎜>
//Above This code can also be abbreviated as
function _rebuild_array($arr){ //rebuild a array
if(is_array($arr[$i])) _rebuild_array($arr[$i]);
else $tmp[]=$arr[$i ];
return $tmp;
}
$arr = array_2to1( $array );
foreach( $arr as $v )
echo $v;
}
//Now let’s look at an example of saving one-dimensional data to two-dimensional data
$arr_new=array();
//Now we write the two arrays into a new two-dimensional array in one-to-one correspondence
$arr_new[$val]=$insert_value[$key];
print_r($arr_new);
www.bkjia.com