サブ配列の値に基づいて配列を分割しやすくするPHP関数または他のソリューションはありますか?部分配列値に基づく分割PHP配列
はい、ループでこれを行うことができます。ループスルーなしでそれを行う別の方法があるかどうかです。この配列中に活性の値を使用して
、この配列を回す...
$array_all => Array
(
[126] => Array
(
[DisplayName] => Customer ABC
[Active] => 1
)
[1596] => Array
(
[DisplayName] => Customer 123
[Active] => 0
)
[1648] => Array
(
[DisplayName] => John Q Sample
[Active] => 1
)
[1649] => Array
(
[DisplayName] => Fry & Leela, Inc.
[Active] => 0
)
[1571] => Array
(
[DisplayName] => Class Action: Redshirts vs. UFP
[Active] => 1
)
)
... ...
$array_active => Array
(
[126] => Array
(
[DisplayName] => Customer ABC
[Active] => 1
)
[1648] => Array
(
[DisplayName] => John Q Sample
[Active] => 1
)
[1571] => Array
(
[DisplayName] => Class Action: Redshirts vs. UFP
[Active] => 1
)
)
...:
例この配列。
$array_inactive => Array
(
[1596] => Array
(
[DisplayName] => Customer 123
[Active] => 0
)
[1649] => Array
(
[DisplayName] => Fry & Leela, Inc.
[Active] => 0
)
)
'array_filter'または' array_reduce'ですか? – Fabricator
何があってもループがあります。なぜ誰もが "ループなし"を求めるのです –
@ダゴン - あなたのデータをループする必要がないことが時々あります。したがって、言語機能。たとえば、文字列をループして各文字を大文字にすることができますが、これは一般的な作業です。そのため、PHPはstrtoupper()を提供しています。はい、ループがありますが、大文字の文字列が必要なたびに処理する必要はありません。 array_filterのDitto - 私の現在のプロジェクトではよくあることですが、PHPをビルドする前にPHPが組み込まれているかどうかを知りたかったのです。文字通り私がやりたかったことの名前であるarray_filter()を考えなかったのはちょっと恥ずかしいです... – Eli