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 Quote 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 Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.