Jump to content

ereg_replace


arfa

Recommended Posts

I would recommend not using ereg, as of PHP6, it will not be supported in the core by default (I think it will only be an extension). You should use preg instead. Here is a good starter thread for that. You can also read about PCRE regex here.

 

$str = 'testing 123...';
$str = preg_replace('#[^a-z0-9]#', '', $str);
echo $str;

 

Ouput:

testing123

Link to comment
https://forums.phpfreaks.com/topic/132164-ereg_replace/#findComment-687041
Share on other sites

Generally there seems to be a very slow uptake of php5

 

Well, PHP 5.3 is now in alpha.. so once that final stable release launches, I assume 6 is next.

I personally am not concerned with how long it takes, so long as each version is developed properly with the least amount of bugs possible while adding robust features.

 

So yes, it may take a while till version 6 finally arrives.. but it's best to future proof your code now.. that way, when version 6 does arrive, your php scripts will not 'mysteriously' break on you.

 

Cheers,

 

NRG

Link to comment
https://forums.phpfreaks.com/topic/132164-ereg_replace/#findComment-689429
Share on other sites

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.