One of the problems in today’s project is that the found results need to be filtered again according to the conditions. Because what is found is a two-dimensional array, the array is traversed directly. The two-dimensional array I use is $list. First traverse it like this:
foreach($list as $k=>$v){ if(strpos($v['distance'],'7.') === 0 &&strrchr($v['distance'],'km')== 'km' ){ $v['distance'] = '7.0km'; } }
foreach($list as $k=>$v){ if(strpos($v['distance'],'7.') === 0 &&strrchr($v['distance'],'km')== 'km' ){ $list[$k]['distance'] = '7.0km'; } }
Copyright Statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.
The above introduces PHP to traverse multi-dimensional arrays and change the values of the arrays, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.