phpseclib-将mysql查询解析为数组
我使用phpseclib在ssh2上执行mysql选择查询 我把结果拿回来了。如果我加上nl2br,它是可读的,每一行都在一个单独的行上。但我仍然无法访问行的列 如何将phpseclib ssh2 mysql查询的输出正确解析为递归数组 这是我如何进行查询的: $output=$ssh->exec'mysql-uMyUser-pMyPassword MyTable-e SELECT*FROM users LIMIT' 执行str_replace\t,“,”,$output可能会起作用 以下是如何将其放入关联数组中的方法—不是您所要求的,但它可以帮助您了解输出的格式:phpseclib-将mysql查询解析为数组,php,mysql,sql,ssh,phpseclib,Php,Mysql,Sql,Ssh,Phpseclib,我使用phpseclib在ssh2上执行mysql选择查询 我把结果拿回来了。如果我加上nl2br,它是可读的,每一行都在一个单独的行上。但我仍然无法访问行的列 如何将phpseclib ssh2 mysql查询的输出正确解析为递归数组 这是我如何进行查询的: $output=$ssh->exec'mysql-uMyUser-pMyPassword MyTable-e SELECT*FROM users LIMIT' 执行str_replace\t,“,”,$output可能会起作用 以下是如何
$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);