Skip to content

Instantly share code, notes, and snippets.

@codex73
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save codex73/41c8e1787db4750b6ec6 to your computer and use it in GitHub Desktop.

Select an option

Save codex73/41c8e1787db4750b6ec6 to your computer and use it in GitHub Desktop.
<?php
// Multi Dimensional Array Search
private function searchForId($id, $array)
{
$value = '';
foreach ($array as $key => $val)
{
if ($val['hotel_PPID'] == $id)
{
$value = $key;
break;
}
}
//extra logi
if(! empty($value))
{
//do something else
}
return $value;
}
// Usage
if(! empty($this->searchForId($hotel_id,$this->hotelsInfos->hotels_infos)))
{
$bestRate[$hotel_id][$this->current_occupancy]['currency'] = (string)$prices->name;
$bestRate[$hotel_id][$this->current_occupancy]['price'] = (string)$prices->value->double;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment