jcadima
6/7/2017 - 9:29 PM

Find array value by ID

Find array value by ID

https://stackoverflow.com/questions/2970768/find-array-value-using-key

<?php

$product_label = $_product->getData('brand_label');	 // 5

$brands = array(
	'5' => 'Argo',
	'4' => 'Cannon',
	'3' => 'Forus',
	'15' => 'Icare',
	'16' => 'Kowa',
	'7' => 'Optomol',
	'8' => 'Potec',
	'9' => 'Reichert',
	'9' => 'Sonomed Escalon',
	'11' => 'Shin-Nippon',
	'12' => 'Tomey',
	'13' => 'Vissio',	
	'14' => 'Hans Heiss',
	'6' => 'Welch Allyn'
) ;

$key = $product_label ;
// now echo the value by key :  $brands['5']
?>

<img src="<?php  echo  $_product->getData('brand');   ?>" alt="<?php echo $brands[$key] ; ?>">