[PHP] Get the beginning array number

2001-09-17 Thread Brandon Orther

Hello,
 
I have an array sent to my script that starts at different numbers each
time.  Here is an example
 
 
$array[5] through $array[23]  will have values but [0]-[4] will not.
 
Is there a way for me to find the first element of an array with a value?
 
Thank you,


Brandon Orther
WebIntellects Design/Development Manager
[EMAIL PROTECTED]
800-994-6364
www.webintellects.com
  
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


Re: [PHP] Get the beginning array number

2001-09-17 Thread Jason Bell

try this, untested, on the fly type solution.  :)

foreach ($array as $key = $value) {
if (strlen($value)  0) {
$FirstWithValue = $key;
break;
}
}

Now, $FirstWithValue should hold the key of the first element, so you could
then use $array[$FirstWithValue]


if you are using php older than version 4, exchange the foreach loop with a
while loop.


- Original Message -
From: Brandon Orther [EMAIL PROTECTED]
To: PHP User Group [EMAIL PROTECTED]
Sent: Monday, September 17, 2001 4:46 PM
Subject: [PHP] Get the beginning array number


 Hello,

 I have an array sent to my script that starts at different numbers each
 time.  Here is an example


 $array[5] through $array[23]  will have values but [0]-[4] will not.

 Is there a way for me to find the first element of an array with a value?

 Thank you,

 
 Brandon Orther
 WebIntellects Design/Development Manager
 [EMAIL PROTECTED]
 800-994-6364
 www.webintellects.com
 









 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]