Whitespacing in processing strings.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • William Cheung

    Whitespacing in processing strings.

    Hi all,

    I am a relative newbie to the PHP language but at present I am trying
    to write some code that would process text (in a string, not an
    array)by the explode() method. Basically, I want to seperate different
    words out by using the explode(" ", $text); command, yet I find that
    this approach tends to die when I perform this on strings taken from
    texts with carriage returns in.

    Any suggestions to tackling this problem would be greatly appreciated!


    William Cheung
  • Erwin Moller

    #2
    Re: Whitespacing in processing strings.

    William Cheung wrote:
    [color=blue]
    > Hi all,
    >
    > I am a relative newbie to the PHP language but at present I am trying
    > to write some code that would process text (in a string, not an
    > array)by the explode() method. Basically, I want to seperate different
    > words out by using the explode(" ", $text); command, yet I find that
    > this approach tends to die when I perform this on strings taken from
    > texts with carriage returns in.[/color]

    Hi William,

    dies?
    I don't believe that.
    I think you made a mistake in your code instead causing it to loop forever.
    Please post the relevant PHP-code so we can check.
    [color=blue]
    >
    > Any suggestions to tackling this problem would be greatly appreciated!
    >
    >
    > William Cheung[/color]

    Regards,
    Erwin Moller

    Comment

    • Eric Ellsworth

      #3
      Re: Whitespacing in processing strings.

      Hi William,
      Haven't tested this, but it occurs to me that you may be able to remove
      the carriage returns with strstr. If that fails, try preg_split:


      Good luck,

      Eric

      "William Cheung" <gaioshin@hotma il.com> wrote in message
      news:3295aa91.0 310220445.7c80f b04@posting.goo gle.com...[color=blue]
      > Hi all,
      >
      > I am a relative newbie to the PHP language but at present I am trying
      > to write some code that would process text (in a string, not an
      > array)by the explode() method. Basically, I want to seperate different
      > words out by using the explode(" ", $text); command, yet I find that
      > this approach tends to die when I perform this on strings taken from
      > texts with carriage returns in.
      >
      > Any suggestions to tackling this problem would be greatly appreciated!
      >
      >
      > William Cheung[/color]


      Comment

      Working...