Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #8570
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: returning values from a 2d array |
| Date | 2013-03-07 11:26 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <khaf0m$bs1$1@dont-email.me> (permalink) |
| References | <ewh1yyqb5sh0$.1ff3g2zafy3ux$.dlg@40tude.net> |
On 3/7/2013 10:49 AM, richard wrote:
> 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);
> $num=anum
> $number="0" . $num;
> 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: ");
> $top[1960][2]= array("He'll Have To Go "," In A Mansion Stands My Love ","
> Jim Reeves "," RCA Victor 7643 "," Composer: J. Allison, A. Allison ","
> Arranger: "," Producer: Chet Atkins "," Composer: Johnny Russell ","
> Arranger: "," Producer: Chet Atkins ");
> $top[1960][3]= array("Cathy's Clown "," Always It's You "," Everly Brothers
> "," Warner Bros. 5151 "," Composer: Don Everly, Phil Everly "," Arranger:
> "," Producer: "," Composer: B. Bryant, F. Bryant "," Arranger: ","
> Producer: ");
> $top[1960][4]= array("Running Bear "," My Heart Knows "," Johnny Preston
> "," Merucry 71474 "," Composer: J. P. Richardson "," Arranger: ","
> Producer: "," Composer: J. P. Richardson, J. Preston "," Arranger: ","
> Producer: ");
> $top[1960][5]= array("Teen Angel "," Bye Now Baby "," Mark Dinning "," MGM
> 12845 "," Composer: J. Surrey, R. Surrey "," Arranger: "," Producer: ","
> Composer: Bryant "," Arranger: "," Producer: ");
>
$top is a three dimensional array and would be indexed as
$top[$x][$y][$z]. For instance, "Theme From a Summer Place" would be
$top[1960][1][0] and "Composer: J. P. Richardson" would be
$top[1960][4][4].
I think you're going about this the wrong way, but hey - it's your code.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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