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.net but all functions accept

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 aj...@alumni.iu.edu 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

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; foreach

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

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=

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'): ?php $viz_ip= $_SERVER['REMOTE_ADDR']; echo (Your IP is $viz_ip); $byte_ip= array( 204.126.202.56=Mark, 63.230.76.166=Bob, 84.196.101.86=John, ); function _array_search

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 trying

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'): ?php $viz_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 not in the

Re: [PHP] array search

2001-08-31 Thread Andrey Hristov
from http://php.net/quickref.php $os = array (Mac, NT, Irix, Linux); if (in_array (Irix, $os)){ print Got Irix; } Andrey HristovIcyGEN Corporationhttp://www.icygen.comBALANCED SOLUTIONS - Original Message - From: Joseph Bannon [EMAIL PROTECTED] To: PHP (E-mail) [EMAIL

Re: [PHP] array search

2001-08-31 Thread Philip Olson
just to add some info. rememember this is case sensitive and spaces do matter, sometimes (depending on your goals) the following will apply : $good_names = array('jim','philip','sasheen'); $my_name= 'PHiliP'; if (in_array(trim(strtolower($my_name)),$good_names)) and, another good

RE: [PHP] array search

2001-08-31 Thread Alfredeen, Johan
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 take a look

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 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

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 name

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 sentence into parts

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 names, like below...