[PHP] Re: Get the beginning array number

2001-09-18 Thread _lallous

reset($array);
list(, $value) = each($array);
this will give you first value in $value

Brandon Orther [EMAIL PROTECTED] wrote in message
!~[EMAIL PROTECTED]">news:!~[EMAIL PROTECTED]...
 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] Re: Get the beginning array number

2001-09-18 Thread Steve Edberg

At 4:12 PM +0200 9/18/01, _lallous wrote:
reset($array);
list(, $value) = each($array);
this will give you first value in $value


...and according to

http://www.php.net/manual/en/function.reset.php

reset() returns the first element of the array, so you could shorten this to

$value = reset($array);

But if you need the key value as well, you (I think) WILL have to do 
it _lallous' way:

reset($array);
list($key, $value) = each($array);

For more info, see

http://www.php.net/manual/en/ref.array.php

-steve



Brandon Orther [EMAIL PROTECTED] wrote in message
!~[EMAIL PROTECTED]">news:!~[EMAIL PROTECTED]...
  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
  
  


-- 
+ Open source questions? +
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- http://pgfsun.ucdavis.edu/open-source-tools.html ---+

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