通过使用result_array我有这样的数组:
Array ( [0] => Array ( [toid] => 34 ) [1] => Array ( [toid] => 37 ) )
但是,我想要正常的数组,因为我需要将其传递给查询。
答案 0 :(得分:2)
您可以使用array_column
$arr = .... //Your not so normal array here
$normalArr = array_column($arr, 'toid');
echo "<pre>";
print_r( $normalArr );
echo "</pre>";
这将导致:
Array
(
[0] => 34
[1] => 37
)
Doc:array_column
答案 1 :(得分:0)
//Old Array
$Old_Array = array(
array(
"toid" => 34
),
array(
"toid" => 37
)
);
//Output => Array ( [0] => Array ( [toid] => 34 ) [1] => Array ( [toid] => 37 ) )
//Converting to a normal New Array
$New_Array = array();
foreach ( $Old_Array as $Items )
$New_Array[] = $Items["toid"];
//Output => Array ( [0] => 34 [1] => 37 )