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

Home » Imported messages » comp.lang.php » how to assign a variable string from an array?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: how to assign a variable string from an array? [message #172453 is a reply to message #172452] Fri, 18 February 2011 20:12 Go to previous message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma:
Senior Member
On Fri, 18 Feb 2011 21:04:18 +0100, Luuk wrote:

> On 18-02-11 20:54, richard wrote:
>> $a=array(1=>
>> array("John","123 Adams","555-0102","electrician"),
>> array("Bob","234 Quincy","555-7788","barber"),
>> array("Charles","756 Capitol","555-9090","teacher")
>> )
>
> // John,Bob, Charles
> echo "Names: \n<br>";
> for ($x=1; $x<count($a[1]); $x++ ) {
> echo $a[$x][0]."\n<br>";
> }
>
> // Adresses
> echo "Addresses: \n<br>";
> for ($x=1; $x<count($a[1]); $x++ ) {
> echo $a[$x][1]."\n<br>";
> }

Thanks.
I think I see what you're doing. Reassigning the main array values into an
array you call $x then using that array as the base.

http://1littleworld.net/modalbox/

As I have the text shown in <ul> format, how would I go about assigning a
value to each of the names so that a for loop would not be necessary?
Or would the loop be better?
I would need some way of matching up the linked item with what is in the
array.
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: simple modal box to display info
Next Topic: Adult only
Goto Forum:
  

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

Current Time: Fri Nov 29 02:33:13 GMT 2024

Total time taken to generate the page: 0.04183 seconds