Jump to content

Converting information seperated by commas in string into array?


pioneerx01

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.