Home > Backend Development > PHP Tutorial > 求一段PHP代码解决方案

求一段PHP代码解决方案

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 13:18:34
Original
903 people have browsed it

求一段PHP代码
trim($_POST['tag'])的值为:11,你好|12,他好|13,我好|14,都好|15,大家好
让下面5个值分别等于
$tagsql['tag1']=11
$tagsql['tag2']=12
$tagsql['tag3']=13
$tagsql['tag4']=14
$tagsql['tag5']=15

代码应当怎么写,麻烦知道的大哥直接给完整代码谢谢了!

------解决方案--------------------
老牛拉破车的循环

PHP code

$str = '11,你好|12,他好|13,我好|14,都好|15,大家好';
$arr = array();
if (!empty($str)) {
    preg_match_all('/(\d{2})/', $str, $match);
    $i = 0;
    foreach ($match[1] as $value) {
        ++$i;
        $arr['tag' . $i] = $value;
    }
} else {
    for ($i = 1; $i 
                 
              
              
        
            
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