[英]How to extract the datas from an array with different field in PHP?
My array is:我的数组是:
Array ( [0] => 652, 5850 [1] => 230, 9850 [2] => 201 ,13700 )
I stored the data by using this code:我使用以下代码存储数据:
$myarray=array();
if(!empty($_GET['check_list'])) {
// Loop to store and display values of individual checked checkbox.
foreach($_GET['check_list'] as $selected) {
$myarray[]=$selected;
}
print_r($myarray);
}
I want to extract this data like:我想提取这些数据,如:
[roomno] =>652,230,201
[price] =>5850,9850,13700
How can I get this value?我怎样才能得到这个值?
Here is one possible way :这是一种可能的方法:
<?php
$array = [
0 => [652, 5850],
1 => [230, 9850],
2 => [201 ,13700]
];
$roomno = [];
$price = [];
foreach($array as $a){
$roomno[] = $a[0];
$price[] = $a[1];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.