error in preg_replace

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
crishna369
Forum Newbie
Posts: 10
Joined: Mon May 25, 2009 12:35 am

error in preg_replace

Post by crishna369 »

My Code is :

Code: Select all

$cod = 4;
$temp = preg_replace($cod, '', $tp, 1);
Error is :
Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash in /home/kthakkar/public_html/crm/insert.php on line 245
Last edited by Benjamin on Wed May 27, 2009 10:02 am, edited 1 time in total.
Reason: Added [code=php] tags.
ramya123
Forum Newbie
Posts: 13
Joined: Thu Sep 11, 2008 6:11 am

Re: error in preg_replace

Post by ramya123 »

Pattern matching String should always be enclosed with delimiters. You are missing delimiters.
for example: preg_replace("/hi/", "hello", "hi test");
In this example / is the delimiter.
Post Reply