Jump to content

willpower

Members
  • Posts

    296
  • Joined

  • Last visited

About willpower

  • Birthday 09/05/1972

Profile Information

  • Gender
    Male
  • Location
    Warrington, Cheshire, UK

willpower's Achievements

Member

Member (2/5)

0

Reputation

  1. Found this...which works... <?php function in_object($val, $obj){ if($val == ""){ trigger_error("in_object expects parameter 1 must not empty", E_USER_WARNING); return false; } if(!is_object($obj)){ $obj = (object)$obj; } foreach($obj as $key => $value){ if(!is_object($value) && !is_array($value)){ if($value == $val){ return true; } }else{ return in_object($val, $value); } } return false; } ?> Usage : <?php $array = array("a", "b", "c"=>array("x", "y"=>array("p", "q"=>"r"))); if(in_object("r", $arrX)){ echo "r is there "; }else{ echo "Its not there "; } ?>
  2. Hi and welcome. You havent had any responses as your question is a little vague. Perhaps if you explain what you have accomplished, what you have tried and what is failing...maybe by posting some of your code, any errors you get, etc you may get more help. Will
  3. Whats the most efficient way of searching within a multi dimensional array? My Array = Array ( [0] => Array ( [0] => Item 1 [title] => Item 1 [1] => 2012-03-21 [eventDate] => 2012-03-21 [2] => 21 [eventDay] => 21 ) [1] => Array ( [0] => Item 2 [title] => Item 2 [1] => 2012-03-21 [eventDate] => 2012-03-21 [2] => 21 [eventDay] => 21 ) ) String to find = '21' If (MY ARRAY contains STRING TO FIND) {} Clearly in this case there are several '21' (s) so if I only wanted to search the [eventDay] keys...would there be a fast effective and efficient manner? Thoughts and help gratefully received. Will
×
×
  • 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.