Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

find object in array php

$people = array(
  2 => array(
    'name' => 'John',
    'fav_color' => 'green'
  ),
  5=> array(
    'name' => 'Samuel',
    'fav_color' => 'blue'
  )
);

$colors = array_column($people, 'fav_color');
$found_key = array_search('blue', $colors);

var_dump($people[$found_key])
Source by www.php.net #
 
PREVIOUS NEXT
Tagged: #find #object #array #php
ADD COMMENT
Topic
Name
1+8 =