本文共 377 字,大约阅读时间需要 1 分钟。
#id name passwd $str = '1 tom 123 2 jack 4565 absk 435345';$arr = explode("\n", $str);$result = [];$title = ['id', 'name', 'passwd'];foreach ($arr as $item) { if (empty(trim($item))) { continue; } $temp = preg_split('/[\s]+/', $item); $temp = array_combine($title, array_filter($temp)); $result[] = $temp;}var_dump($result);
转载地址:http://hksib.baihongyu.com/