I want to change an string to array but I get problem with it:
This my code to make array
function parse_response($response) {
if (is_array($response)) {
$PARSED = array();
$CURRENT = null;
for ($i = 0, $imax = count($response); $i < $imax; $i++) {
if (in_array($response[$i], array('!fatal', '!re', '!trap'))) {
if ($response[$i] == '!re')
$CURRENT = &$PARSED[];
else
$CURRENT = &$PARSED[$response[$i]][];
}
else
if ($response[$i] != '!done') {
if (preg_match_all('/[^=]+/i', $response[$i], $MATCHES))
$CURRENT[$MATCHES[0][0]] = (isset($MATCHES[0][1]) ? $MATCHES[0][1] : '');
}
}
return $PARSED;
}
else
return array();
}
but I get Warning: preg_match_all() expects parameter 2 to be string, array given in /home/hamed4u/public_html/routeros_api.class.php on line 171
How can I fix it!!
output string
Quote
[20, 142] =primary-dns=4.2.2.4 >>> [22, 119] =secondary-dns=8.8.8.8 >>> [28, 90] =allow-remote-requests=false >>> [24, 65] =max-udp-packet-size=512 >>> [16, 48] =cache-size=2048 >>> [25, 22] =cache-max-ttl=1w00:00:00 >>> [13, 8] =cache-used=6 >>> [5, 1]


Sign In
Create Account


Back to top









