Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] splitting characters ?

Expand Messages
  • Tom Barron
    ... You can also get to individual characters in a string without creating an extra array with substr(): for ($idx = 0 ; $idx
    Message 1 of 3 , Aug 24, 2000
    • 0 Attachment
      Gamaliel Lagman wrote:
      >
      > On Thu, 24 Aug 2000, Nathan Rimmer wrote:
      > ...
      > #>But what I want to do is to split a single word into
      > #>its individual characters and then process it.
      > #>
      > #>IE
      > #>split "wibble" into "w" "i" "b" "b" "l" and "e"
      > #>
      > #>I'm struggling on what to split on - ie I cant use
      > #>blank spaces or | as I have done for other splits.
      > #>...
      > Still use the basic split.
      >
      > @array = split //, $string;
      >
      > Split it witout any characters in between the slashes "//" it should
      > segregate the characters from the string.

      You can also get to individual characters in a string without creating
      an extra array with substr():

      for ($idx = 0 ; $idx < length($string) ; $idx++)
      {
      $chr = substr($string,$idx,1);
      # do something with $chr
      }

      Tom
    Your message has been successfully submitted and would be delivered to recipients shortly.