This is a discussion on parsing words within the PHP Language forums, part of the PHP Programming Forums category; I have an array and I want to fetch it and get each values that starts with "col" ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I noticed that Message-ID:
<39615087.0408231409.68d10c80@posting.google.com > from kindermaxiz@yahoo.com contained the following: >I have an array and I want to fetch it and get each values that starts >with "col" in the array and do something with them, how can I do that? For each value in the array use substr() to see if the first three letters =="col" http://uk2.php.net/manual/en/function.substr.php -- Geoff Berrow (put thecat out to email) It's only Usenet, no one dies. My opinions, not the committee's, mine. Simple RFDs http://www.ckdog.co.uk/rfdmaker/ |
|
|||
|
kindermaxiz@yahoo.com wrote:
> I have an array and I want to fetch it and get each values that starts > with "col" in the array and do something with them, how can I do that? array_filter() or even better, array_keys() with optional value. http://ch.php.net/manual/en/function.array-keys.php Aphrael. -- "La demande mondiale d’ordinateurs n’excédera pas cinq machines." (Thomas Watson, Fondateur d'IBM, 1945) |
|
|||
|
kindermaxiz@yahoo.com wrote in message news:<39615087.0408231409.68d10c80@posting.google. com>...
> I have an array and I want to fetch it and get each values that starts > with "col" in the array and do something with them, how can I do that? let $array be your array foreach ($array as $i => $value) { $line = $array[$i]; $tok = strtok($string," \n\t"); if($tok == "col") do something } |