Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个字符串变量,它具有以下格式的多个值:
123, xyz, abc
它甚至可能只有一个值(在这种情况下,后面不会有任何逗号)
如何在for循环中解析这些值,一次遍历每个值?
for
$input="123, xyz, abc"; foreach (explode(",",$input) as $value) { var_dump(trim($value)); }
尝试用逗号' , '来爆炸
$your_arr = "123,xyz,...."; $my_arr = explode(",",$your_arr); foreach($my_arr as $arr) { echo $arr; //Do the stuff HERE }