Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Printing Text From Nested Arrays.
Old 12-20-2008, 11:12 PM Printing Text From Nested Arrays.
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
So, for this video hosting script I'm working on, ive ran into this problem.

I'm a very visual learner so if i can't "see" the MySQL Data i don't like to use them, and this script can be used by people who don't have access to a MySQL database.

Problem: Ive got the videos set up in an array so they are "sorted", and ive got the .flv link, discription, and tag in an array inside of that.

Ex:
PHP Code:
// $video[$n] = array("file.flv","Description","tag");
$video[0] = array("intro.flv","Intro To Decaf Video","Help");
$video[1] = array("Michael_Angelo_Batio_Double_Guitar_Solo.flv","Dual Hand Gutiar Solo","Music");
$video[3] = array("amazing_guitar_player.flv","Guy plays with his feet","Music");
$video[4] = array("BBC_Horizon_The_Six_Billion_Dollar_Experiment.flv","Particle Acclerator","Educational");
$video[5] = array("Bush_Shoe_Thrown.flv","Bush Shoe Throw","News");
$video[6] = array("Charlie_the_Unicorn.flv","Charlie The Unicorn","Funny");
$video[7] = array("Charlie_the_Unicorn_2.flv","Charlie The Unicorn 2","Funny"); 
My question is how can i get that description to print?

I have tried:
PHP Code:
print "$video[$n][2]";
// And
print "$video[$n]array[2]"
Fyi, the $n is just the video number called from the URL/Random Generator.

Any help would be appericated, thanks.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


Last edited by Decaf; 12-20-2008 at 11:14 PM..
Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
 
Register now for full access!
Old 12-21-2008, 04:13 AM Re: Printing Text From Nested Arrays.
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
Ditch the quotes.

PHP Code:
$n=7;
print 
$video[$n][2]; // funny 
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 12-21-2008, 12:55 PM Re: Printing Text From Nested Arrays.
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Thanks max, that helped.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Old 12-22-2008, 04:33 AM Re: Printing Text From Nested Arrays.
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
If you need to print the value inside a string you should use curly brackets.
PHP Code:
echo "Our most recent video {$video[$n][2]} has already got 1 million views"
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 12-22-2008, 11:07 AM Re: Printing Text From Nested Arrays.
Decaf's Avatar
Ultra Talker

Posts: 489
Name: Adam
Trades: 0
Yep, thanks guys. I think i understand it enough now to make this guide. And my video sharing script is using it for now (untill i get around to making it mySQL).

Thanks guys!
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Decaf is offline
Reply With Quote
View Public Profile Visit Decaf's homepage!
 
Reply     « Reply to Printing Text From Nested Arrays.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15140 seconds with 12 queries