Results 1 to 3 of 3

Thread: help replacing split() please.

  1. #1
    Join Date
    Apr 2004

    resolved help replacing split() please.

    I have the following code aand understand split()is deprecated - please can someone help out with replacement code.

    PHP Code:
    foreach ($lines as $l) {
      if (
    trim($l) != "") {
    $t = (array)split("\r\n"trim($l));
        if (
    $t[1] == 'TRUE'$total_items++;



  2. #2
    Join Date
    Aug 2004
    PHP Code:
    $t preg_split('/\r\n/'trim($l)); 
    However, since you are not doing anything that requires the use of a regular expression, I would just use explode():
    PHP Code:
    $t explode("\r\n"trim($l)); 
    (Although from the variable name "$lines", it at least sounds a bit strange that there would be carriage-return/newlines within each line, especially after trim()-ing any that might be at the end of the line?)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

  3. #3
    Join Date
    Apr 2004
    Thanks for that.

    It is correct - it is analysing a string that has been stored in a text file, which originates from a user multi-line input text box.

    But - then I didn't code the original app and aren't a PHP coder hence the request - the app works, except for the warning since our ISP upgraded PHP


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles