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 #180636 is a reply to message #180633] Thu, 07 March 2013 16:48 Go to previous messageGo to previous message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma:
Senior Member
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.
[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:38 GMT 2024

Total time taken to generate the page: 0.03823 seconds