Jump to content

[SOLVED] str_replace not working as it should...


NucleaDisasta

Recommended Posts

k so i'm developing a webapp where people will paste a Copy paste of a webpage (not the source) from firefox and then it will spit out some results. The problem is though that for the regex i have in place i need to rip out the "newline" and "tab" characters before the regex will "see" the patterns i'm looking for.

 

I've tested the patterns i'm looking for on an input that has had the "newline" and "tab" characters removed before being input and it works perfectly.

 

The piece of code i am using to strip out the "newline" and "tab" characters is thus:

    // Strip line breaks, commas and tabs
    $line_breaks = array('\r\n', '\n', '\r', '\t', ',');
    $nationUse = str_replace($line_breaks, "", $nationIn); 

 

Now this piece of code is stripping out the commas from the input so I know that its doing something. It is not stsripping out any of the rest of the characters though and i'm at a loss as to why. Any ideas?

 

Also the server this issue is happening on has a PHP version of 5.2.6

works fine m8......

<?php
    
    $nationIn="<html><head><title></title></head><body> hi there\r\n i am redaarow\n how are you\r yee\t haa,</body></html>";
    $line_breaks = array("\r\n", "\n", "\r", "\t", ",");
    $nationUse = str_replace($line_breaks, " ", $nationIn);
    
    echo $nationUse;
    
    ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.