FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » returning values from a 2d array
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: returning values from a 2d array [message #180639 is a reply to message #180636] Thu, 07 March 2013 17:04 Go to previous messageGo to previous message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma:
Senior Member
On Thu, 07 Mar 2013 17:48:16 +0100, M. Strobel wrote:

> Am 07.03.2013 16:49, schrieb richard:
>> I have been searching the web for an answer but can't really find what I
>> want to know.
>>
>> How do I retrieve the values from an array once the random number has been
>> generated?
>> In BASIC, one would simply say: show$=top$(1960,1).
>> In PHP though, it seems you have to go through a miriad of loops just to
>> find out if the value exists.
>>
>> So how is this done properly?
>>
>>
>> <?php
>>
>> anum=rand(1,40);
> Error, missing $
>
>> $num=anum
> Error, missing ;
>> $number="0" . $num;
> Looks like nonsens.
>> if ($num<10) {$number="0" . $number;}
>> if (Snum>=100) {$number=$num;}
>>
>> $top[1960][0]= array("top 100 1960");
>> $top[1960][1]= array("Theme From A Summer Place "," Go-Go-Po-Go "," Percy
>> Faith "," Columbia 41490 "," Composer: Max Steiner"," Arranger: ","
>> Producer: "," Composer: Percy Faith "," Arranger: "," Producer: ");
>
> What are you trying to do? Pick one song randomly?
>
> Then look at your array:
>
> echo $top[1960][1][0] would give "Theme From A Summer Place"
>
> Just put rand(0,9) as index of the third level, and the rest ... don't know what you
> want.
>
> And it is quite near to PHP array abuse, there must be a better representation.
>
> /Str.

the randomizing feature works quite well.
www.mroldies.net/playertest.php
which randomly selects one of 40 songs each time the page is reloaded.

what I am wanting to do is, print the information for the song below the
player.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Need help with updating ereg_replace function -> to preg_replace
Next Topic: Bowling
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Dec 18 07:00:59 GMT 2024

Total time taken to generate the page: 0.04379 seconds