?
Solved

Function ereg_replace() is deprecated

Posted on 2009-12-18
3
Medium Priority
?
2,074 Views
Last Modified: 2013-12-13
Hello,

A CMS script that we use has some use of deprecated php functions since php 5.3.0 which is now throwing errors..

Function ereg_replace() is deprecated

I need a quick fix on the following ereg_replace function to make it compatible with php 5.3 so that it uses preg_replace instead.
$processedTitle = ereg_replace('[^a-zA-Z0-9\\'.$space.']', '', $processedTitle); // strip the rest
    $processedTitle = ereg_replace('\\'.$space.'+',$space,$processedTitle); // Convert multiple 'spaces' to a single one
    $processedTitle = trim($processedTitle,$space);

Open in new window

0
Comment
Question by:thyros
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
hsq91 earned 2000 total points
ID: 26084493
Simple!

$processedTitle = preg_replace('/[^a-zA-Z0-9\\'.$space.']/', '', $processedTitle); // strip the rest
    $processedTitle = preg_replace('/\\'.$space.'+/',$space,$processedTitle); // Convert multiple 'spaces' to a single one
    $processedTitle = trim($processedTitle,$space);
0
 

Author Closing Comment

by:thyros
ID: 31667970
Excellent, thanks very much!!!!!
0
 

Author Comment

by:thyros
ID: 26084661
Top man, thanks alot, your quick response saved me from a stressful night trying to troubleshoot it.

Thanks again.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question