PHP

Hi Friends,

I need some help on PHP programming

Array
(
[0] => Array
(
[title] => Mobiles & Accessories
)

[1] => Array
    (
        [title] => Mobile Accessories
    )

[2] => Array
    (
        [title] => Cables
    )

)
Array
(
[0] => Array
(
[title] => Computers
)

[1] => Array
    (
        [title] => TV & Video Accessories
    )

[2] => Array
    (
        [title] => Cables
    )

)
Array
(
[0] => Array
(
[title] => Home Entertainment
)

[1] => Array
    (
        [title] => Video Players & Accessories
    )

[2] => Array
    (
        [title] => Video Accessories
    )

[3] => Array
    (
        [title] => Cables
    )

)
Array
(
[0] => Array
(
[title] => Home Entertainment
)

[1] => Array
    (
        [title] => Audio Players
    )

[2] => Array
    (
        [title] => Audio Player Accessories
    )

[3] => Array
    (
        [title] => Cables
    )

)
Array
(
[0] => Array
(
[title] => Computers
)

[1] => Array
    (
        [title] => Audio Players
    )

[2] => Array
    (
        [title] => Audio Player Accessories
    )

[3] => Array
    (
        [title] => Cables
    )

)

I am having arrays in this type

I want to assign each top level arrays to unique variable. Please help me to resolve this problem. I am very much thanks to all those who are initiated to this problem

The first thing I would do is figure how you want to setup the array, for example if I was doing something this I would I would do it this way:

[php]<?php

$equipment = [
‘computers’ => [‘apple’, ‘dell’, ‘hp’],
‘TV & Video Accessories’ => [‘speakers’, ‘universal remotes’, ‘tv stands’],
‘cable’ => [‘audio’, ‘video’, ‘speaker’]
];

echo ‘

’ . print_r($equipment, 1) . ‘
’ . “\n”;[/php]

I would associative array names for the indexes, that way it would be easier to remember.

Sponsor our Newsletter | Privacy Policy | Terms of Service