Using preg_match on a multidimensional array to return key values arrays

后端 未结 6 997
情话喂你
情话喂你 2020-12-17 05:13

I have an array that is structured as such:

$data = array(
    \"abc\"=>array(
            \"label\" => \"abc\",
            \"value\" => \"def\",
          


        
6条回答
  •  北荒
    北荒 (楼主)
    2020-12-17 05:52

    If you are using PHP 5.5 and are viewing this question in 2015, this might be a more simple answer:

    $elements= array_column($array, 1); //Where 1 is the name of the column or the index
    $foundElements = preg_grep("/regex/i", $elements);
    

提交回复
热议问题