I am having difficulties in exploding string by "-" and creating a new array.
I get values in an array over checkbox from the HTML table. Values are in the string which needs to be separated by "-" and form new array under array (array example below).
At the end I should get array[0]
[0]=>002251/18
[1]=>1
[2]=>1000
[3]=>5500.00
[4]=>800
I need final output:
if(isset($_POST["submit"])){
$paketi = array();
$prikolica = $_POST["truck"];
$nalozi[] = $_POST["items"];
}
nalozi[] -> OUTPUT
array(1) {
[0]=>
array(3) {
[0]=>
string(28) "002251/18-1-1000-5500.00-800"
[1]=>
string(28) "002251/18-2-1000-5500.00-800"
[2]=>
string(28) "002251/18-3-1000-5500.00-800"
}
}
$_POST["items"];is an array and you're not looping it (or setting it correctly) to construct your secondary array, you're just dumping the whole contents into the first key