parsing words

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


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-24-2004
kindermaxiz@yahoo.com
 
Posts: n/a
Default parsing words

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?
Reply With Quote
  #2 (permalink)  
Old 08-24-2004
Geoff Berrow
 
Posts: n/a
Default Re: parsing words

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/
Reply With Quote
  #3 (permalink)  
Old 08-24-2004
Aphrael
 
Posts: n/a
Default Re: parsing words

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)
Reply With Quote
  #4 (permalink)  
Old 08-24-2004
Excluded_Middle
 
Posts: n/a
Default Re: parsing words

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
}
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:09 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0