Re: solved! Re: Filling an array with random input doesn't quite work [message #185221 is a reply to message #185219] |
Thu, 13 March 2014 02:43 |
Mr Oldies
Messages: 241 Registered: October 2013
Karma:
|
Senior Member |
|
|
On Thu, 13 Mar 2014 01:11:59 +0100, Christoph Michael Becker wrote:
> Tim Streater wrote:
>
>> In article <85dkidwa0h67(dot)ecj3ezgrqtzk$(dot)dlg(at)40tude(dot)net>, richard
>> <noreply(at)example(dot)com> wrote:
>>
>> You're welcome.
>>
>>> $x=1;
>>> while ($x<40){
>>> $yr=rand(1,10);
>>> $yr=$yr+59;
>>> $num=rand(1,100);
>>> if ($num<100){$num="0".$num;}
>>> if ($num<10){$num="0".$num;}
>>
>> What is the point if this second "if"? You've already covered that with
>> the first.
>
> That serves to add padding to three characters. The last three lines
> could be replaced with the following:
>
> str_pad(rand(1, 100), 3, '0', STR_PAD_LEFT);
>
>>>
>>> $song[$x]="http://mroldies.net/audio/19$yr/".$yr."-".$num.".mp3";
>>> $x++;
>>> }
thanks for the clue. I may use it.
|
|
|