Jump to content

search in array


poe

Recommended Posts

this is one way:

 

<?php
function get_si ( $array, $olg ) {
  foreach($sptAry $keys){
    if($keys['olg'] == $olg)
      return $keys['si'];
  }
  return false;
}
$sptAry = array(
'hockey' => array( 'olg'=>'hky', 'si'=>'nhl', ),
'baseball' => array( 'olg'=>'bbl', 'si'=>'mlb', ),
);
print get_si($sptAry,'hky');
?>

Link to comment
https://forums.phpfreaks.com/topic/97115-search-in-array/#findComment-496949
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.