PHP waits for a method online. I have an Array (& nbsp; [P1211007] & nbsp ;=& gt; & nbsp; 2 & nbsp; & nbsp; [P1211008] & nbsp; = & gt; & nbsp; 3 & nbsp;) currently there are 2 PHP online waiting methods.
I have an array
Array
(
[P1211007] => 2
[P1211008] => 3
)
There are currently two rows of data, and the number of rows may not be determined.
I want to standardize this data into such data
Array
(
[1] => Array
(
[P1211007] => Array
(
[Pcode] => P1211007
[Book_num] => 2
)
[P1211008] => Array
(
[Pcode] => P1211008
[Book_num] => 3
)
)
)
I am a newbie in PHP. you can help me.
------ Best solution --------------------
$ar=Array
(
'P1211007' => 2,
'P1211008' => 3
);
$arr=$new_arr=array();
foreach($ar as $k=>$v){
$arr[$k]=array('pcode' =>$k,'book_num' => $v);
}
$new_arr[1]=$arr;
print_r($new_arr);
------ Other solutions --------------------
No one else ..
------ Other solutions --------------------
Thank you,