Hi, I have an array as follows, I need only array[2] and array[3], how can I extract only these two array? Some time there will be more than two hosts, in essence I need all the array values between array[1] and the array that that has the string "registrations.". How can I do this?
Array
(
[0] => Privilege: Command
[1] => Host username password
[2] => host01 user1 pw01
[3] => host02 user2 pw02
[4] => 2 registrations.
[5] =>
[6] => Follows
)
Thanks of the help.
A
PHP Warning: array_push() expects parameter 1 to be array, null given in /var/www/registryShowCli.p
PHP Warning: array_push() expects parameter 1 to be array, null given in /var/www/registryShowCli.p
My code is as follows:
$peer = implode("\n", $peer);//puts the whole thing in an array
$row = explode("\n", $peer);//puts each line in an array
print_r($row);
for($i = 2; $i < sizeof($row); $i++){
if(strpos($row[$i], 'registrations.') !== false) {
break;
}else{
array_push($rows, $row[$i]);
}
}
print_r($rows);