I have arrays $devices,$port
print_r($devices);
Array(
[0] => cisco1
[1] => cisco2
)
print_r($port);
Array
(
[0] => Port1/1/1
[1] => Port1/1/10
[2] => Port1/1/11
)
I want to create an array $devlist which would be something like this:
Array(
[cisco1] =>Port1/1/1
Port1/1/10
Port1/1/11
[cisco2] =>Port2/1/1
Port2/1/10
Port2/1/11
)
My point is there is an array of devices($devices) and arrays of ports that are there in each of the device. The $port array gets created newly for each device in the $device array.
What i have tried so far:
foreach ($devices as $value)
{
$port=();
//iam polling the respective device and getting a list of ports available for that device in array **$port**
array_push($devices[$value], $port);
}
This method generates an error "array_push() expects parameter 1 to be array, null given"
Kindly excuse me if this seems an easy question becoz iam new to php and scripting as well:(