PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
tecktalkcm0391
DevNet Resident
Posts: 1030 Joined: Fri May 26, 2006 9:25 am
Location: Florida
Post
by tecktalkcm0391 » Thu Dec 21, 2006 11:56 am
How could I convert this type of categorizing to an array..
The format is
Code: Select all
Main Category
Sub Category
Sub-Sub Category
So an example would be
Code: Select all
Home
Kitchen
Applicances
Cookware
Bathroom
Living Room
TVs
Computer
Desktop
Laptops
Laptop Batteries
Cabin Items
Digital Cameras
HP
Jcart | Switched to tags[/color]
Begby
Forum Regular
Posts: 575 Joined: Wed Dec 13, 2006 10:28 am
Post
by Begby » Thu Dec 21, 2006 12:53 pm
Are those tabs? Is this a text string? Where are these categories coming from like that?
wtf
Forum Contributor
Posts: 331 Joined: Thu Nov 03, 2005 5:27 pm
Post
by wtf » Thu Dec 21, 2006 2:28 pm
maybe something like this
Code: Select all
<?php
$a = array( 'Home' => array( 'Kitchen' => array( 'Appliances', 'Cookware' ),
'Baathroom' => '',
'Living Room' => 'Tvs'),
'Computer' => array( 'Desktops' => '', 'Laptops' => 'Laptop Batteries' ),
'Cabin Items' => '',
'Digital Cameras' => array( 'HP' )
);
print_r ($a);
?>
kingconnections
Forum Contributor
Posts: 137 Joined: Thu Jul 14, 2005 4:28 pm
Post
by kingconnections » Thu Dec 21, 2006 2:32 pm
You can use a multi dimensional array for this.
Ie say you have this type of layout:
Products --Product Description --- Price
The array would look like so:
Code: Select all
$items = array( array( 'Product' => 'Tire',
'Description => 'Goodyear Tires',
'Price => '100.00'
),
array( 'Product' => 'OIL',
'Description => 'Purple Royal Oil',
'Price => '100.00'
)
);