I'd like to search an array of products by a specific value and return a sibling value. For example, searching for barcode 4325, should return the ID 2135. What is the best way to do this in PHP?
$products = array(
array(
'id' => 2135,
'title' => 'Product 1',
'variants' => array(
'barcode' => '4325',
),
),
array(
'id' => 234,
'title' => 'Product 2',
'variants' => array(
'barcode' => '2355',
),
)
);