Re: ereg_replace help!

From: Date: Wed, 23 Aug 2000 18:12:07 +0000
Subject: Re: ereg_replace help!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-13196@lists.php.net to get a copy of this message
hi, see the manual: One thing to take note of is that if you use an integer value as the replacement parameter, you may not get the results you expect. This is because ereg_replace() will interpret the number as the ordinal value of a character, and apply that. For instance: Example 2. ereg_replace() Example <?php /* This will not work as expected. */ $num = 4; $string = "This string has four words."; $string = ereg_replace('four', $num, $string); echo $string; /* Output: 'This string has words.' */ /* This will work. */ $num = '4'; $string = "This string has four words."; $string = ereg_replace('four', $num, $string); echo $string; /* Output: 'This string has 4 words.' */ ?> so in your case try : $temp = '-'; $string = eregi_replace ("\\", $temp, $string); andreas viva technologies > > I have a string: > > $string = "it belongs in the category animals\dogs"; > > I want to replace the \ with - > > $string = eregi_replace ("\\", "-", $string); > > > When i try this i get: > > Warning: REG_EESCAPE in test.php on line 6 > > > Why???? > > > i can replace the \\ to a letter like a, and the error goes away. > > help! > > > chris > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#13196) next »