php-general Digest 24 Apr 2011 15:44:47 -0000 Issue 7282
Topics (messages 312466 through 312467):
Re: webserviceX.net?
312466 by: jomali
str_replace
312467 by: Ron Piggott
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
I tested it with my current address, and it did not know my current area
code, which has been what it is for at least ten years.
jomali
On Sat, Apr 23, 2011 at 2:36 PM, Brian Dunning <[email protected]>wrote:
> I'm looking for some geographic data, like ZIP codes, area codes, but it
> has to be current and correct. Has anyone ever used the free web services at
> webserviceX.net? Do you know anything about the data? How current/correct is
> it? Seems to be an awful lot they're giving away for free.
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
I am trying to figure out a syntax that will replace each instance of % with
a different letter chosen randomly from the string $puzzle_filler.
$puzzle_filler is populated with the letters of the alphabet, roughly in the
same ratio as they are used.
This syntax replaces each instance of % with the same letter:
$puzzle[$i] = str_replace ( "%" , ( substr ( $puzzle_filler , rand(1,98) ,
1 ) ) , $puzzle[$i] );
Turning this:
%ECARBME%TIPLUP%%%%%%%E%%
Into:
uECARBMEuTIPLUPuuuuuuuEuu
Is there a way to tweak my str_replace so it will only do 1 % at a time, so
a different replacement letter is selected?
This is the syntax specific to choosing a replacement letter at random:
substr ( $puzzle_filler , rand(1,98) , 1 );
Thanks for your help.
Ron
The Verse of the Day
“Encouragement from God’s Word”
http://www.TheVerseOfTheDay.info
--- End Message ---