[PHP] array_search and in_array

2006-07-12 Thread Jo�o C�ndido de Souza Neto
Hi everyone. I´m facing a big trouble that a don understand why is it happenin. I´ve got an array with 1046 elements in it like this. Here is a part of a print_r of my array. Array ( [0] = 0001-01 [1] = 0003-01 [2] = 0140-01 [3] = 0141-01 [4] = 0142-01 [5] = 0170-03 [6] = 0181-01 [7] =

Re: [PHP] array_search function bugged? update

2006-03-27 Thread Robin Vickery
On 27/03/06, je killen [EMAIL PROTECTED] wrote: Hi all Here is an update on my problem reported with the array_search function. to those who directed me to the bug report page, thanks. There are a number of reports specific to this function. Maybe event someone else has written a fix. here

[PHP] array_search function bugged? update

2006-03-26 Thread je killen
Hi all Here is an update on my problem reported with the array_search function. to those who directed me to the bug report page, thanks. There are a number of reports specific to this function. Maybe event someone else has written a fix. here is my solution to my problem. The following code* was

[PHP] array_search function bugged update errata

2006-03-26 Thread je killen
sorry all for the mistake in the code; in this line 'array $input' should be string $input. function word_wise(array $input, int $what) //returns an array so it reads function word_wise(string $input, int $what) //returns an array this should be the only mistake. I added this stuff as an

Re: [PHP] array_search function bugged?

2006-03-21 Thread Richard Lynch
On Mon, March 20, 2006 8:35 pm, je killen wrote: I really don't understand, though, why you are doing things the way you describe... I only want one image file for each distinct letter, no repeats because I can't put two or more files with the same name in the same dir. The images need to

Re: [PHP] array_search function bugged?

2006-03-21 Thread Richard Lynch
On Mon, March 20, 2006 8:47 pm, je killen wrote: I am using simple for loops. If I create and populate an array and test it with a print statement in a for loop, it prints out all the current values. It I again call it to print in a for loop in subsequent code it has exhibited a degraded

Re: [PHP] array_search function bugged?

2006-03-21 Thread Jim Lucas
Richard Lynch wrote: On Mon, March 20, 2006 8:35 pm, je killen wrote: I really don't understand, though, why you are doing things the way you describe... I only want one image file for each distinct letter, no repeats because I can't put two or more files with the same name in the

Re: [PHP] array_search function bugged?

2006-03-20 Thread Richard Lynch
On Sun, March 19, 2006 4:46 pm, je killen wrote: The following code does not produce the correct results (for my purposes): function code($str, $match, $formula) { for($i = 0; $i count($str); $i++) { $formula[$i] = array_search($str[$i], $str);// ==|| no bueno //print

[PHP] array_search function bugged?

2006-03-19 Thread je killen
The following code does not produce the correct results (for my purposes): function code($str, $match, $formula) { for($i = 0; $i count($str); $i++) { $formula[$i] = array_search($str[$i], $str);// ==|| no bueno //print $formula[$i]; not right if($formula[$i] $i) {$str[$i] = '';}

Re: [PHP] array_search function bugged?

2006-03-19 Thread Richard Davey
On 19 Mar 2006, at 22:46, je killen wrote: The code takes a string of ascii letters forming a word and is supposed to create a list of indexes in the proper sequence for reconstructing the word. The object of the code in context is to take Ignoring your code (and the supposed 'bug') for a

Re: [PHP] array_search and multi-dimensional arrays

2006-03-14 Thread List Manager
jonathan wrote: I'd like to return the first key value in the following array such that England would return 1 rather than 3 which is the second key value. Any help would be greatly appreciated. $c[1][]=Vietnam; $c[1][]=China; $c[1][]=Thailand; $c[1][]=England; $c[2][]=USA; $c[2][]=Japan;

Re: [PHP] array_search and multi-dimensional arrays

2006-03-14 Thread M. Sokolewicz
List Manager wrote: jonathan wrote: I'd like to return the first key value in the following array such that England would return 1 rather than 3 which is the second key value. Any help would be greatly appreciated. $c[1][]=Vietnam; $c[1][]=China; $c[1][]=Thailand; $c[1][]=England;

Re: [PHP] array_search and multi-dimensional arrays

2006-03-14 Thread List Manager
M. Sokolewicz wrote: List Manager wrote: jonathan wrote: I'd like to return the first key value in the following array such that England would return 1 rather than 3 which is the second key value. Any help would be greatly appreciated. $c[1][]=Vietnam; $c[1][]=China; $c[1][]=Thailand;

Re: [PHP] array_search and multi-dimensional arrays

2006-03-13 Thread jonathan
looks like this works. Is there any problem with it that people can see? $c[1][]=Vietnam; $c[1][]=China; $c[1][]=Thailand; $c[1][]=England; $c[2][]=USA; $c[2][]=Japan; print_r($c); foreach($c as $key=$value) { if(array_search(England,$value)) { echo $key; } } thanks,

Re: [PHP] array_search and multi-dimensional arrays

2006-03-13 Thread Philip Thompson
On Mar 13, 2006, at 5:54 PM, jonathan wrote: I'd like to return the first key value in the following array such that England would return 1 rather than 3 which is the second key value. Any help would be greatly appreciated. $c[1][]=Vietnam; $c[1][]=China; $c[1][]=Thailand; $c[1][]=England;

[PHP] array_search() with preg_match?

2005-06-23 Thread René Fournier
I need to search an array for a string, with a twist. E.g.: $array = array(0 = 'this sky is blue', 1 = 'pencils are orange', 2 = 'I like green apples', 3 = 'strawberries are red'); $key = array_search('green', $array); With the above code, nothing will be returned, but I would like it to

[PHP] array_search does not find the first element

2004-03-31 Thread Merlin
Hi there, I am trying to find values inside an array. This array always starts with 0. unfortunatelly array_search start searching with the array element 1. So the first element is always overlooked. How could I shift this array to start with 1, or make array-search start with 0? The array comes

Re: [PHP] array_search does not find the first element

2004-03-31 Thread Tom Rogers
Hi, Wednesday, March 31, 2004, 10:20:06 PM, you wrote: M Hi there, M I am trying to find values inside an array. This array always starts with 0. M unfortunatelly array_search start searching with the array element 1. M So the first element is always overlooked. M How could I shift this array

Re: [PHP] array_search does not find the first element

2004-03-31 Thread John Holmes
Merlin wrote: I am trying to find values inside an array. This array always starts with 0. unfortunatelly array_search start searching with the array element 1. So the first element is always overlooked. Please read the text inside the big Warning box on the following page:

[PHP] array_search

2003-11-20 Thread Jake McHenry
I've been using array_search in my scripts for a while now, but have come across a problem. My new page has a textarea field. If I enter any new lines in the textarea, array_search returns false. I have tried using html_encode, addslashes, serialize and nothing yet has worked. My only other

RE: [PHP] array_search

2003-11-20 Thread Jay Blanchard
[snip] I've been using array_search in my scripts for a while now, but have come across a problem. My new page has a textarea field. If I enter any new lines in the textarea, array_search returns false. I have tried using html_encode, addslashes, serialize and nothing yet has worked. My only

RE: [PHP] array_search

2003-11-20 Thread Jake McHenry
-Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Thursday, November 20, 2003 2:48 PM To: Jake McHenry; [EMAIL PROTECTED] Subject: RE: [PHP] array_search [snip] I've been using array_search in my scripts for a while now, but have come across a problem. My

RE: [PHP] array_search

2003-11-20 Thread Jake McHenry
-Original Message- From: Jake McHenry [mailto:[EMAIL PROTECTED] Sent: Thursday, November 20, 2003 2:51 PM To: 'Jay Blanchard' Cc: [EMAIL PROTECTED] Subject: RE: [PHP] array_search -Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Thursday

RE: [PHP] array_search

2003-11-20 Thread Kelly Hallman
On Thu, 20 Nov 2003, Jay Blanchard wrote: $foo = $_POST['textarea']; $newFoo = str_replace(\n, , $foo); $arrayFoo = explode( , $newFoo); In the code above any spaces on the lines will also be delimiters... I missed that part of the requirement...? Maybe I'm not understanding the problem, but

Re: [PHP] array_search

2003-11-20 Thread CPT John W. Holmes
From: Jake McHenry [EMAIL PROTECTED] I've been using array_search in my scripts for a while now, but have come across a problem. My new page has a textarea field. If I enter any new lines in the textarea, array_search returns false. [snip] Kinda stuck here.. Not sure what I should try next...

[PHP] Array_search wildcard

2003-03-21 Thread Liam Gibbs
Is there such a thing as an array_search wildcard? Say I want to find anything beginning with RE and having zero or more characters following it, how would I do that?

Re: [PHP] Array_search wildcard

2003-03-21 Thread Marek Kilimajer
$found=array(); foreach($array as $key = $value) { if(ereg('RE.+',$value)) { // optionaly use eregi for case insensitiveness $found[$key]=$value; } } Liam Gibbs wrote: Is there such a thing as an array_search wildcard? Say I want to find anything beginning with RE and having zero

Re: [PHP] Array_search wildcard

2003-03-21 Thread Liam Gibbs
$found=array(); foreach($array as $key = $value) { if(ereg('RE.+',$value)) { // optionaly use eregi for case insensitiveness $found[$key]=$value; } } Thanks, Marek. With some minor adjustments, this worked out fine! -- PHP General Mailing List (http://www.php.net/) To

[PHP] array_search() problem

2002-09-12 Thread David Orn Johannsson
Hi I'm runing a PHP Version 4.0.4pl1 on Solaris 8 X86 on apache, and I'm trying to search an array while(list($findId) = mysql_fetch_row($resultNextLast)){ $NextLast[] = $findId; } $currArrayPos = array_search($ImgId, $NextLast); and this code results this error: Fatal error: Call to

Re: [PHP] array_search() problem

2002-09-12 Thread Bas Jobsen
Hi I'm runing a PHP Version 4.0.4pl1 on Solaris 8 X86 on apache, and I'm trying to search an array From the manual: array_search (PHP 4 = 4.0.5) send earlier to this list: Re: [PHP] Array - Match From: Bas Jobsen [EMAIL PROTECTED] To: N. Pari Purna Chand [EMAIL PROTECTED], [EMAIL

Re: [PHP] array_search() problem

2002-09-12 Thread Bas Jobsen
What I was looking for was finding out what was the index of thet value, lets say I have a array with some values like (23, 56, 45, 47) and i don't know where the walue I'm looking for is indexed in the array and I want to find out what the indexnumber is, how would that be possable ?

[PHP] array_search in 2-d arrays

2002-05-14 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 in 2-d arrays

2002-05-14 Thread Pushkar Pradhan
Regarding my recent post, I am sorry $key is not undefined it is just 0 or FALSE. 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

[PHP] array_search

2002-04-25 Thread andy
thats why you do not have a key which is not found. Try to replace $findme withthis: $findme = array('banana', 'cranberry', 'not in there'); Will return: Key () was found for value not in there So there is a bug.. but well hidden :-( Von: Kevin Stone [EMAIL PROTECTED] An: PHP-general [EMAIL

[PHP] array_search

2002-02-26 Thread Roger Keays
Hi, Can anybody explain why the output of this script is not found Found! Here is the script... $legalfields = array(reasonForRepair); if (array_search(reasonForRepair, $legalfields) == TRUE) { echo Found!br; } else { echo not foundbr; } $legalfields = array(foo, reasonForRepair);

Re: [PHP] array_search

2002-02-26 Thread Lars Torben Wilson
On Tue, 2002-02-26 at 01:29, Roger Keays wrote: Hi, Can anybody explain why the output of this script is not found Found! Yup. array_search() returns the key of the found object, as noted in the docs (http://www.php.net/array_search). Since the first test has the searched-for field at

Re: [PHP] array_search

2002-02-26 Thread Edward van Bilderbeek - Bean IT
is not the same type as FALSE)... Greets, Edward - Original Message - From: Roger Keays [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, February 26, 2002 10:29 AM Subject: [PHP] array_search Hi, Can anybody explain why the output of this script is not found Found! Here is the script

[PHP] array_search()

2001-10-27 Thread Ashley M. Kirchner
I'm trying to figure out how am I supposed to write this snippet properly: if (($index = array_search($search, array_keys($pages))) !== false) { echo index: $index\n; } else { echo Not found\n; } When I search for something that I know exists, it returns the $index just fine.

[PHP] array_search()

2001-10-26 Thread Ashley M. Kirchner
I'm trying to figure out how am I supposed to write this snippet properly: if (($index = array_search($search, array_keys($pages))) !== false) { echo index: $index\n; } else { echo Not found\n; } When I search for something that I know exists, it returns the $index just fine.

[PHP] array_search

2001-06-20 Thread Steen Rabol
Hi How to figure out of a value is found using array_search ? eg: $myarray = array(val1,val2,val3); if(array_search(val2,$myarray)) { print Value found; } the above will work, but... if(array_search(val1,$myarray)) { print Value found; } the above will not work as val1 is key 0, how