How to grab seperated integers from long string

我是研究僧i 提交于 2019-12-18 09:49:19

问题


I am working on a enrollment system for a judo club. I am using a string to store the ID's of people, who showed up. It looks somthing like this:

0,3,4,7,8,10,

Now, I want to seperate each number into an integer array in PHP. What would the simplest solution to this be? :)


回答1:


Use explode()

$ids = explode(',', '0,3,4,7,8,10');



回答2:


$str = '0,3,4,7,8,10';
$arr = explode(',',$str);



回答3:


use EXPLODE

$num = "0,3,4,7,8,10";
$pieces = explode(",", $num );
  • Explode Manual


来源:https://stackoverflow.com/questions/14777796/how-to-grab-seperated-integers-from-long-string

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!