Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #8572

Re: returning values from a 2d array

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!pnx.dk!fu-berlin.de!uni-berlin.de!not-for-mail
From "M. Strobel" <sorry_no_mail_here@nowhere.dee>
Newsgroups comp.lang.php
Subject Re: returning values from a 2d array
Date Thu, 07 Mar 2013 17:48:16 +0100
Lines 42
Message-ID <aprumgF1d1iU1@mid.uni-berlin.de> (permalink)
References <ewh1yyqb5sh0$.1ff3g2zafy3ux$.dlg@40tude.net>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de 55aAHJieLtMA8yqd5wMreAdNhEl53CxKYw0TsontbnERlse6VdkP0EJc6IeCLTj2c=
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3
In-Reply-To <ewh1yyqb5sh0$.1ff3g2zafy3ux$.dlg@40tude.net>
Xref csiph.com comp.lang.php:8572

Show key headers only | View raw


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.

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

returning values from a 2d array richard <noreply@example.com> - 2013-03-07 10:49 -0500
  Re: returning values from a 2d array Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-07 11:26 -0500
    Re: returning values from a 2d array richard <noreply@example.com> - 2013-03-07 11:31 -0500
      Re: returning values from a 2d array "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-03-07 17:50 +0100
      Re: returning values from a 2d array "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-03-07 18:02 +0100
      Re: returning values from a 2d array Jerry Stuckle <jstucklex@attglobal.net> - 2013-03-07 14:41 -0500
  Re: returning values from a 2d array "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2013-03-07 17:48 +0100
    Re: returning values from a 2d array richard <noreply@example.com> - 2013-03-07 12:04 -0500
  Re: returning values from a 2d array Alastair Black <abqab.nemo@example.net> - 2013-03-07 15:00 -0700

csiph-web