在PHP中,我的数组如下所示。
Array ([0] => Array ( [ReasonCode] => TS ) [1] => Array ( [ReasonCode] => TS3 ) [2] => Array ( [ReasonCode] => TS4 ) [3] => Array ( [ReasonCode] => TEST-OO1 ) [4] => Array ( [ReasonCode] => ROO1 ) ).
但我希望我的数组如下Array(TS,TS3,TS4,TEST-001,ROO1)
。
答案 0 :(得分:0)
Let Your be $reasonCode = Array(0 => Array ( 'ReasonCode' => "TS"),
1 => Array ( 'ReasonCode' => "TS3" ),
2 => Array ( 'ReasonCode' => "TS4"),
3 => Array ( 'ReasonCode' => "TEST-OO1"),
4 => Array ( 'ReasonCode' => "ROO1"));
$result = [];
foreach ($reasonCode as $reasonCodeKeys => $reasonCodeValue) {
foreach ($reasonCodeValue as $reasonkey => $reasonValue) {
$result[]=$reasonValue;
}
}
echo "<pre>";
print_r($result);
echo "</pre>";
exit;