
运行命令:
$output = shell_exec("adb devices -l");echo "$output";并获得这样的输出:
List of devices attached10.16.21.138:5555 device product:tbltevzw model:SM_N915V device:tbltevzw10.16.20.90:5555 device product:ghost_verizon model:XT1060 device:ghost有人可以帮助将这些信息存储到PHP关联数组中吗?
解决方法:
// remove extra spaces, then split into array by new lines$arr = explode("\n", preg_replace('/ +/',' ',$x));array_shift($arr); // remove 1-st line$result = Array();foreach($arr as $v){ $tmp = explode(' ',$v); // split each line into words List($ip,$port) = explode(':',$tmp[0]); $item = Array('ip'=>$ip, 'port'=>$port); array_shift($tmp); // remove IP:PORT array_shift($tmp); // remove DEVICE foreach($tmp as $n) { List($key,$data) = explode(':',$n); // split by : $item[$key] = $data; // accumulate key/data pairs } $result[] = $item; // append device to the result array} 总结 以上是内存溢出为你收集整理的java – 如何将网络上的adb设备列表存储到php数组中全部内容,希望文章能够帮你解决java – 如何将网络上的adb设备列表存储到php数组中所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)