Re: Help with str_replace()
| From: | Shawn McKenzie | Date: | Wed, 03 Feb 2016 19:13:24 +0000 |
| Subject: | Re: Help with str_replace() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-325378@lists.php.net to get a copy of this message | ||
Where did you read that str_replace() uses regular expressions? May
preg_replace().
On Wed, Feb 3, 2016 at 12:06 PM, Danny <mynixmail@gmail.com> wrote:
> Hi guys,
>
> Can someone tell me why I am getting no output from the following file ...
>
> Explanation:
> I send a number (via procmail) to this script. This script in turn takes
> the
> number ... opens up a file ... search for the previous number ... replace
> the
> previous number with the new number ... and then writes it to the file ...
>
>
> ###############################################################################################
> #!/usr/bin/php
> <?php
> while ( false !== ( $input = fgets ( STDIN ) ) )
> {
> $old_number = "/((NUMBER_ID=)([0-9]{1,6}))/" ;
>
> $new_number = "NUMBER_ID=".$input ;
>
> $number_file = "NumberRotation.conf" ;
>
> $file_contents = file_get_contents ( $number_file,
> FILE_USE_INCLUDE_PATH ) ;
> $file_contents = str_replace ( $old_number, $new_number,
> $file_contents ) ;
>
> file_put_contents ( $number_file, $file_contents ) ;
> }
> ?>
>
> ###############################################################################################
>
> Thank You
> Danny
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>