$str="
有这么一段字符串 通过php处理字符串,得到 一个新的数组(名字,count值);
比如生成 $ars=array('0'=>'谢姣','0'=>'毕丹丹','0'=>'马朝莉','0'=>'李欣','1'=>'李萍');
求各大侠帮帮忙,感激不尽
$str="<v:note id='33' count='0'>谢姣</v:note> <v:note id='34' count='0'>毕丹丹</v:note> <v:note id='35' count='0'>马朝莉</v:note> <v:note id='36' count='0'>李欣</v:note> <v:note id='37' count='1'>李萍</v:note>"; preg_match_all("/<v:note id=\'\d+\' count=\'(\d)\'>(.*?)<\/v:note>/", $str, $matches); $newArr = array_combine($matches[2],$matches[1]); var_dump($newArr);?> 不可能生成你要的这种。相同的key是不可以同时存在的。后者会覆盖前者。
只能array('0'=>'谢姣','1'=>'毕丹丹','2'=>'马朝莉','3'=>'李欣','4'=>'李萍'); 类似这样。
你的count不能做key的
$str="<v:note id='33' count='0'>谢姣</v:note> <v:note id='34' count='0'>毕丹丹</v:note> <v:note id='35' count='0'>马朝莉</v:note> <v:note id='36' count='0'>李欣</v:note> <v:note id='37' count='1'>李萍</v:note>"; preg_match_all("/<v:note id=\'\d+\' count=\'(\d)\'>(.*?)<\/v:note>/", $str, $matches); $newArr = array_combine($matches[2],$matches[1]); var_dump($newArr);?> 不可能生成你要的这种。相同的key是不可以同时存在的。后者会覆盖前者。
只能array('0'=>'谢姣','1'=>'毕丹丹','2'=>'马朝莉','3'=>'李欣','4'=>'李萍'); 类似这样。
你的count不能做key的 我只要能头按照count 里面的值进行排序
没有string哪里的string 是你其他地方输出的吧
没有string哪里的string 是你其他地方输出的吧 谢谢你 给分
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号