Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php从字符串中查找字符之间的值_Php_String_Char - Fatal编程技术网

php从字符串中查找字符之间的值

php从字符串中查找字符之间的值,php,string,char,Php,String,Char,考虑字符串1,2,3,4 我想提取1234并将其存储在数组中。此代码 for($i=0; $i<strlen($multi_event_value); $i++) { if(is_numeric(substr($multi_event_value,$i,1))) { $multi_event[$t] = substr($multi_event_value,$i,1); $t++; } } 用于($i=0;$i使用 st

考虑字符串1,2,3,4

我想提取1234并将其存储在数组中。此代码

for($i=0; $i<strlen($multi_event_value); $i++)
{
    if(is_numeric(substr($multi_event_value,$i,1)))
    {       
        $multi_event[$t] = substr($multi_event_value,$i,1);
        $t++;
    }
}
用于($i=0;$i使用


string.split(separator,limit)这两个参数都是可选的

使用普通的
explode()
函数或正则表达式。为什么要投反对票呢?问这样的问题不对吗?javascript任何函数都是这样吗?在JS中,你需要调用string对象的
split
方法。例如:
“1,2,3,4”。split(“,”)
想详细介绍一下您的答案吗?我们鼓励您精心设计和解释答案(只是不要写博文:)
$arr = explode(',', '1,2,3,4'); // $arr = array('1', '2', '3', '4');