私は元の配列内に配列と内容をネストしています。ヌル値のネストした配列を削除するPHP
$ myarrayの
[0] => Array(
[ID] => 1
[Fruit] => Apple
[State] => Ohio
[description]
Array(
[0] => This is sample description
[1] => This is sample description 2
[2] =>
[3] =>
[4] =>
)
[price]
Array(
[0] => 20
[1] => 15
[2] =>
[3] =>
[4] =>
)
[1] => Array(
[ID] => 1
[Fruit] => Apple
[State] => Ohio
[description]
Array(
[0] => This is sample description
[1] => This is sample description 2
[2] =>
[3] =>
[4] =>
)
[price]
Array(
[0] => 20
[1] => 15
[2] =>
[3] =>
[4] =>
)
like-配列見た目の内容は、私はネストされた配列にnull
値を取り除きたいです。私は以下を使用する場合:
$newArray = array();
foreach ($firstArray as $row){
if ($row !== null)
$newArray[] = $row;
}
echo $newArray;
新しい配列は、配列内のnull
値を取り除くしません。
'array_filter'あなたは' empty'値の – ThisGuyHasTwoThumbs
チェックを探しているドロイドすぎるヌル比較 –
と交換してください問題の配列を 'var_export($ myArray)'の出力で表示するか、またはサンドボックスを提供します。 – axiac