Re: ereg_replace or chr bug?
| From: | Ando | Date: | Thu, 28 Mar 2002 13:08:16 +0000 |
| Subject: | Re: ereg_replace or chr bug? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-90510@lists.php.net to get a copy of this message | ||
Not sure what you mean here
$text= ereg_replace('&#([0-9]+);' , chr('\1') , $text);
should replace for example "A" with chr('65') (\1 means everything in
brackets in regular expression), which is 'A' .
Rick Emery wrote:
> From the manual for chr()
>
> Returns a one-character string containing the character specified by ascii.
>
> It replaces one (1) character, not a string
>
> -----Original Message-----
> From: Ando [mailto:c980775@ttu.ee]
> Sent: Thursday, March 28, 2002 6:59 AM
> To: php-general@lists.php.net
> Subject: [PHP] ereg_replace or chr bug?
>
> Ok, what i wanna do is replace the codes in html with ascii equivalents:
>
> $text= ereg_replace('&#([0-9]+);' , chr('\1') , $text);
> But somehow it doesnt work, i have no idea why.
>
> When i use
> $text= ereg_replace('&#([0-9]+);' , '\1' , $text);
> it replaces everything correctly
>
> But
> $text= ereg_replace('&#([0-9]+);' , chr('\1') , $text);
> just replaces everything with an empty string
>
> using php 3.0.12
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php