I am looking for some information on how to do this the correct way,
here is the data I am working with:
Array
(
[hostname-0] => hostname
[mac-0] => 00:0a:b3:aa:00:5d
[ip-0] => 192.168.0.1
[subnet] => MMC-Subnet
[group] => MMC-PXE
[hostname-1] => tester01
[mac-1] => 00:09:02:bb:cc:zz
[ip-1] => 192.168.0.2
[hostname-2] => new-test
[mac-2] => 00:09:02:bb:cc:99
[ip-2] => 192.168.0.3
[cmd] => edit
[import] => Re-submit
)
Here is how I need the above data to look when finished processing.
Array
(
[0] => Array
(
[0] => hostname
[1] => 00:0a:b3:aa:00:5d
[2] => 192.168.0.1
)
[1] => Array
(
[0] => tester01
[1] => 00:09:02:bb:cc:zz
[2] => 192.168.0.2
)
[2] => Array
(
[0] => new-test
[1] => 00:09:02:bb:cc:99
[2] => 192.168.0.3
)
)
here is the code I am using.
<?PHP
function ReFilter( $new ) {
$x = 0;
foreach( $new as $key => $value ) {
if( eregi( 'hostname', $key ) ) {
echo "HOSTNAME: " . $key . " => " . $value . "<br>";
$arr[$x] = $value;
}
if( eregi( 'mac', $key ) ) {
echo "MAC: " . $key . " => " . $value . "<br>";
$arr[$x] = $value;
}
if( eregi( 'ip', $key ) ) {
echo "IP: " . $key . " => " . $value . "<br>";
$arr[$x] = $value;
}
if( eregi( 'subnet', $key ) ) {
echo "SUBNET: " . $key . " => " . $value . "<br>";
$arr[$x] = $value;
}
if( eregi( 'group', $key ) ) {
echo "GROUP: " . $key . " => " . $value . "<br>";
$arr[$x] = $value;
}
$x++;
}
$data = $arr;
return $data;
}
?>
I realize I am missing a loop, but am unsure of the best practice on it.
Thanks in advance
--
Jason Gerfen
"You will never be ready for me."
~ Me
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php