I do a mysql select query over ssh2 with phpseclib.
I get my result back. If I add nl2br(), it's kind of readable (every row is on a seperate line). But I still can't access the columns of the rows.
How can I properly parse the output of a phpseclib ssh2 mysql query into a recursive array?
This is how I do my query: $output = $ssh->exec('mysql -uMyUser -pMyPassword MyTable -e "SELECT * FROM users LIMIT"');
Doing str_replace("\\t", ',', $output)
would probably work.
Here's how you'd get it into an associative array (not what you asked but it could prove useful to helping you understanding how the output is formatted):
$output = $ssh->exec('mysql -uMyUser -pMyPassword MyTable -e "SELECT * FROM users LIMIT"');
$output = explode("\n", $output);
$colNames = explode("\t", $output[0]);
$colValues = explode("\t", $output[1]);
$cols = array_combine($colNames, $colValues);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.