Announcement

Collapse
No announcement yet.

chomp in PHP?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • chomp in PHP?

    Is there a PHP function similarly to Perl's chomp?

    Thanks
    Contentteller Community Forums

  • #2
    There is no direct equivalent, but the php chop() function is more like the perl chomp(). It will strip trailing whitespace and newline characters.

    There is definately no perl chop() equivalent in php though.
    http://britishexpats.com/ - British expatriate community

    Comment


    • #3
      Thanks but chop doesn't work. I found in the meantime another solution that work:

      preg_replace("/\s/"," ",$variable);
      Contentteller Community Forums

      Comment


      • #4
        You'll want to use the trim() function.

        Comment


        • #5
          Originally posted by Krucifyx
          You'll want to use the trim() function.
          trim does not act like perls chomp. trim will remove white space and new lines from both sides of the string. rtrim is more similar, although it still removes white space whereas the perl chomp function only removes a new line character.
          http://britishexpats.com/ - British expatriate community

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...
          X