Skip to content

Instantly share code, notes, and snippets.

@Alan01252
Created July 20, 2012 10:07
Show Gist options
  • Save Alan01252/3149984 to your computer and use it in GitHub Desktop.
Save Alan01252/3149984 to your computer and use it in GitHub Desktop.
<?php
public function getContactByKey($key) {
$collection = null;
if($this->getContact()){
$collection = $this->getContact()->filter(function($element) use($key) {return ($element->getKey() === $key) ? $element : null;});
if($collection->current())
return $collection->current()->getValue();
}
return null;
}
public function getContactByKey($key) {
$collection = null;
if($this->getContact()){
foreach($this->getContact() as $contact) {
if($contact->getKey() === $key)
return $contact->getValue();
}
}
return null;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment