[PHP] Array Search

2011-03-25 Thread Ethan Rosenberg
Dear List - Here is a code snippet: $bla = array("g1" => $results[7][6], "h1" => $results[7][7]); print_r($bla); $value = "h1"; $locate1 = array_search($value, $bla); echo "This is locate" ; print_r($locate1); if(in_array($value, $bla)) print_r($b

RE: [PHP] Array Search Problem

2010-03-11 Thread Alice Wei
direction. Alice > From: rene7...@gmail.com > Date: Thu, 11 Mar 2010 07:12:15 +0100 > Subject: Re: [PHP] Array Search Problem > To: aj...@alumni.iu.edu > CC: php-general@lists.php.net > > (almost) all the tricks are in the comments of the help page for a > function, on php.ne

Re: [PHP] Array Search Problem

2010-03-10 Thread Rene Veerman
(almost) all the tricks are in the comments of the help page for a function, on php.net but all functions accept only a given (and usually documented) set of parameter(type)s, so you'll probably have to prepare the var, or even call the function in a loop, outputting to yet another descriptively n

RE: [PHP] Array Search Problem

2010-03-10 Thread Alice Wei
> > did you read the help for those functions on php.net? Yes, I found a "recursive" way to find out the "index" like I wanted, by doing something like $from = explode("-", $from); $state_colors= explode("-", $state_colors); $change = explode("-",$change); $count = count($new_array); $i=0; f

Re: [PHP] Array Search Problem

2010-03-10 Thread Rene Veerman
did you read the help for those functions on php.net? On Wed, Mar 10, 2010 at 4:12 PM, Alice Wei wrote: > > Hi, > >  I have the code as shown in the following that I am trying to create the > image of based on the file loaded into the file and additional edits. The > problem here appears to be

[PHP] Array Search Not Working?

2010-03-10 Thread Alice Wei
Hi, I have two arrays here that I have combined into a new array, as shown here: $from = explode("-", $from); $change = explode("-",$change); $new_array = array_combine($from,$change); I then tried reading it from a file and do string matches, trying to find out the "key" using the array_sea

[PHP] Array Search Problem

2010-03-10 Thread Alice Wei
Hi, I have the code as shown in the following that I am trying to create the image of based on the file loaded into the file and additional edits. The problem here appears to be that no matter what value I have in the $distance_to_destination variable, it does not affect any changes on the

Re: [PHP] array search

2005-01-23 Thread Ben Edwards
probably missing something but php have a function called array_search. Ben On Sun, 23 Jan 2005 11:33:16 -0500 (EST), [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > I've been trying for days now to make this work. > > This worked for me (with my IP address for 'John'): > > $viz_ip= $

Re: [PHP] array search

2005-01-23 Thread Malcolm
Thank you Sirs, I was echoing the viz-ip so I know it was getting set but I couldn't get it. both work .. I got the clue from John, the last echo line did the trick. On Sun, 23 Jan 2005 17:26:58 +0100, Jochem Maas <[EMAIL PROTECTED]> wrote: Malcolm wrote: Hello All, I've been tryin

Re: [PHP] array search

2005-01-23 Thread john
> I've been trying for days now to make this work. This worked for me (with my IP address for 'John'): "Mark", "63.230.76.166"=>"Bob", "84.196.101.86"=>"John", ); function _array_search ($viz_ip, $byte_ip) { foreach($byte_ip as $key => $val) { if ($viz_ip === $key) {

Re: [PHP] array search

2005-01-23 Thread Jochem Maas
Malcolm wrote: Hello All, I've been trying for days now to make this work. I'm trying to search my array for a value and return the key. I get the visitor's IP and try this -- this is the latest, I've tried a few functions to echo the name associated with the viz_ip. $viz_ip= $_SERVER['REMOTE_A

[PHP] array search

2005-01-23 Thread Malcolm
Hello All, I've been trying for days now to make this work. I'm trying to search my array for a value and return the key. I get the visitor's IP and try this -- this is the latest, I've tried a few functions to echo the name associated with the viz_ip. $viz_ip= $_SERVER['REMOTE_ADDR']; $byte_ip

Re: [PHP] array search in 2-D arrays

2002-05-15 Thread Pushkar Pradhan
Oops! Sorry I got a reply for this but didn't read my mail carefully enough. Thanks to Tim Ward for pointing out the problem. > I've a 2 D array and would like to search for vals. in the first dimension > only i.e. > myArray[0][0] > myArray[1][0] > myArray[2][0] > myArray[3][0] > . > . > . > and n

[PHP] array search in 2-D arrays

2002-05-15 Thread Pushkar Pradhan
I've a 2 D array and would like to search for vals. in the first dimension only i.e. myArray[0][0] myArray[1][0] myArray[2][0] myArray[3][0] . . . and not in the elements myArray[0][1] CODE: for($l = 0; $l < count($layer); $l++) { $key = array_search($layer[$l], $layerDes); // $layerDes

RE: [PHP] array search

2001-08-31 Thread Philip Olson
btw, you may want to search for a name surrounded by spaces as philip vs philips, jim vs jimmy, etc. probably other considerations as well, or maybe not :) philip On Fri, 31 Aug 2001, Philip Olson wrote: > try this : > > $people = array ('philip','sasheen','jim'); > $string = 'Hi, my n

RE: [PHP] array search

2001-08-31 Thread Philip Olson
try this : $people = array ('philip','sasheen','jim'); $string = 'Hi, my name is philip, I miss Sasheen'; foreach ($people as $person) { if (stristr($string,$person)) { $matches[] = $person; } } // results live in $matches now. print_r($matches); stristr is case

Re: [PHP] array search

2001-08-31 Thread Martín Marqués
On Vie 31 Ago 2001 17:49, you wrote: > What about going the other way? Say I have a sentence... > > "Hi, my name is Bob." > > ...and I want to search the sentence for one of the values (people) in the > array... > > $people = array("Jim","John","JP","Bob"); > > Can this be done? Yes, split the se

RE: [PHP] array search

2001-08-31 Thread Joseph Bannon
What about going the other way? Say I have a sentence... "Hi, my name is Bob." ...and I want to search the sentence for one of the values (people) in the array... $people = array("Jim","John","JP","Bob"); Can this be done? Thanks, Joseph -Original Message- yes, in_array($person,

RE: [PHP] array search

2001-08-31 Thread Alfredeen, Johan
hat uses a btree or some other type of search methodology. Johan -Original Message- From: Papp Gyozo [mailto:[EMAIL PROTECTED]] Sent: Friday, August 31, 2001 10:02 AM To: Joseph Bannon; PHP (E-mail) Subject: Re: [PHP] array search yes, in_array($person, $people)! however, you may t

Re: [PHP] array search

2001-08-31 Thread Philip Olson
quot;Irix", "Linux"); > if (in_array ("Irix", $os)){ > print "Got Irix"; > } > > Andrey HristovIcyGEN Corporationhttp://www.icygen.comBALANCED SOLUTIONS > - Original Message - > From: "Joseph Bannon" <[EMAIL PROTECTED]> >

Re: [PHP] array search

2001-08-31 Thread Papp Gyozo
yes, in_array($person, $people)! however, you may take a look into the manual. - Original Message - From: Joseph Bannon <[EMAIL PROTECTED]> To: PHP (E-mail) <[EMAIL PROTECTED]> Sent: Friday, August 31, 2001 5:40 PM Subject: [PHP] array search > I have an array of na

Re: [PHP] array search

2001-08-31 Thread Andrey Hristov
- From: "Joseph Bannon" <[EMAIL PROTECTED]> To: "PHP (E-mail)" <[EMAIL PROTECTED]> Sent: Friday, August 31, 2001 6:40 PM Subject: [PHP] array search > I have an array of names, like below... > > $people = array("Jim","John",&quo

[PHP] array search

2001-08-31 Thread Joseph Bannon
I have an array of names, like below... $people = array("Jim","John","JP"); Is there a way in an IF statement to see if someone's name is in the array? Like... if ($people =~ $person) { } I don't want to have to create a foreach loop to go through the array to see if that person is there. Jos