Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 11th, 2005, 05:56 AM
Registered User
 
Join Date: Feb 2005
Location: Male\', Henveiru, Maldives.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to macsham Send a message via MSN to macsham
Default Multidimensional Array

I want to create a multidimensional array of movies organized by genre. This should take the form of an associative array with genres as keys ("SF", "Action", "Romance", and so on). Each of this associative array's elements should be an array containing movie names ("2001", "Alien", "Terminator", and so on).
A Loop through the array , outputting each genre and its associated movies to the browser.

Also can mail me mazu@avasmail.com.mv
chao ;)
Macsham
Reply With Quote
  #2 (permalink)  
Old February 19th, 2005, 11:31 AM
Registered User
 
Join Date: Feb 2005
Location: Stalowa Wola, , Poland.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If u want to create this array:
Code:
<?php
$array = array("SF"=>array('film1', 'film2', 'film3', '...'), 'Action'=>array('film1', 'film2', 'film3', '...'));
?>
and then you can output it using this:
Code:
<?php
foreach($array as $key=>$cat) {
    echo '<B>' . $key . '</b><br />';
    foreach($array[$key] as $movie) {
        echo '&nbsp;&nbsp;&nbsp;--' . $movie . ',<br />';
    }
}
?>

Reply With Quote
  #3 (permalink)  
Old February 24th, 2005, 03:30 PM
Registered User
 
Join Date: Feb 2005
Location: Male\', Henveiru, Maldives.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to macsham Send a message via MSN to macsham
Default

Hi, thanx. I also found one some time back

$movies= array(
    array( name=>"<b>Sci Fixtion</b>",
        one=> "Matrix",
        two=> "Testube"),
    array( name=>"<b>Action</b>",
        two=> "America Black Jangiya",
        three=> "Flying Kik"),
    array( name=>"<b>Comedy</b>",
        one=> "Gods must be crazy",
        two=> "Sponge Bob"));

print "<B>LADIES AND GENTLEMEN WATCH MOVIES LIKE NEVER BEFORE</B><BR><BR>";

foreach ($movies as $num)
{
    foreach ($num as $name => $title)
    {
        print"$title<br>";
    }
    print "<br>";
}

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
multidimensional array help for a newbie grahama PHP Databases 1 May 13th, 2008 09:41 AM
reading data from multidimensional array shish1 Beginning PHP 4 April 1st, 2007 06:42 PM
Multidimensional array in ch9 willburke BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 November 2nd, 2004 04:44 PM
Efficient implementation of multidimensional array Utwig C# 2 October 26th, 2004 04:34 AM
Multidimensional Array help grahama Beginning PHP 0 June 12th, 2004 09:01 PM



All times are GMT -4. The time now is 07:17 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.