php 里怎么让把一串字符分拆出来

WBOY
Release: 2016-06-13 13:19:28
Original
928 people have browsed it

php 里如何让把一串字符分拆出来
字符串是 ||||||||name=小强__job=助理__desc=还行||name=小花__job=秘书__desc=漂亮||||

我想显示成


姓名:小强 职位:助理 评价:还行
姓名:小花 职位:秘书 评价:漂亮

可以像 foreach 一样使用

用 $v[name] 来显示想显示的内容

------解决方案--------------------

PHP code
$s = '||||||||name=小强__job=助理__desc=还行||name=小花__job=秘书__desc=漂亮||||';
foreach( explode('||', str_replace('__', '&', trim($s, '|'))) as $item) {
  parse_str($item, $t);
  $r[] = $t;
}

print_r($r); <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template