pioneerx01 Posted March 14, 2012 Share Posted March 14, 2012 Hi, I am trying to find a way that will allow me to convert information passed via POST into array so I can run foreach on the array. For example if information in $_POST[ids] is 1000, 1001, 1002, 1003 I would like to get it into an array $array = array("1000", "1001", "1002", "1003") Thanks Link to comment https://forums.phpfreaks.com/topic/258873-converting-information-seperated-by-commas-in-string-into-array/ Share on other sites More sharing options...
QuickOldCar Posted March 14, 2012 Share Posted March 14, 2012 By using explode() <?php $_POST['ids']= "1000, 1001, 1002, 1003"; $array = explode(", ",$_POST['ids']); foreach($array as $value) { echo $value . "<br />"; } ?> results: 1000 1001 1002 1003 Link to comment https://forums.phpfreaks.com/topic/258873-converting-information-seperated-by-commas-in-string-into-array/#findComment-1327079 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.