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 #180645 is a reply to message #180633] Thu, 07 March 2013 22:00 Go to previous message
Alastair Black is currently offline  Alastair Black
Messages: 3
Registered: March 2013
Karma:
Junior Member
On 03/07/2013 08: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;}

Check your typing for '$' designating variables. This is
also important when writing BASIC code. anum -> $anum

Check your typing for semi-colons. This is
also important when writing BASIC code. $num=anum -> $num=$anum;

Check 'type'-ing to see that you are not asking to concatenate numeric
variables onto character strings. Leading zero suppression is leading
zero suppression, regardless how many zeroes you put in front.

Alastair
[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: Sat Nov 30 02:53:42 GMT 2024

Total time taken to generate the page: 0.04213 seconds