parsing words

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kindermaxiz@yahoo.com

    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?
  • Geoff Berrow

    #2
    Re: parsing words

    I noticed that Message-ID:
    <39615087.04082 31409.68d10c80@ posting.google. com> from
    kindermaxiz@yah oo.com contained the following:
    [color=blue]
    >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?[/color]

    For each value in the array use substr() to see if the first three
    letters =="col"






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

    Comment

    • Aphrael

      #3
      Re: parsing words

      kindermaxiz@yah oo.com wrote:[color=blue]
      > 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?[/color]
      array_filter() or even better, array_keys() with optional value.
      Return all the keys or a subset of the keys of an array


      Aphrael.
      --
      "La demande mondiale d’ordinateurs n’excédera pas cinq machines."
      (Thomas Watson, Fondateur d'IBM, 1945)

      Comment

      • Excluded_Middle

        #4
        Re: parsing words

        kindermaxiz@yah oo.com wrote in message news:<39615087. 0408231409.68d1 0c80@posting.go ogle.com>...[color=blue]
        > 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?[/color]

        let $array be your array

        foreach ($array as $i => $value) {
        $line = $array[$i];
        $tok = strtok($string, " \n\t");
        if($tok == "col")
        do something
        }

        Comment

        Working...