I am attempting to take array values sent via $_POST from ajax and use the delimitator as the point to split/explode into a usable variable.
Sample of ajax:
function update_dt_reason() {
$.ajax({
url: "inc/daily.update.dt_reason.php?",
type: "post",
data: $('.dt_reasons:checked').serializeArray(),
success: function(data) {
$('#txtNew').html(data);
}
});
};
Example of PHP:
<?php
$testing = print_r($_POST);
$array = array();
$array = explode('|', $testing);
foreach($array as $key => $testing)
{
$array[$key] = explode('|', $testing);
}
echo "<pre>";
print_r($_POST);
?>
Example Output Array:
Array (
[Well] => Array
(
[0] => 1|5
[1] => 1|3
[2] => 1|1
[3] => 1|6
[4] => 1|7
[5] => 1|2
[6] => 1|4
[7] => 2|1
[8] => 2|6
[9] => 2|7
[10] => 2|4
[11] => 3|5
[12] => 3|1
))
Desired output: Either of the below two:
Array ([0] => 1 => 5)
Array ([1] => 1 => 3)
Array ([2] => 1 => 1) etc.
Or, which would be even better:
Array
(
[0] => 1 => Array
(
[0]=>5
[1]=>3
[2]=>1
[3]=>6
[4]=>7
[5]=>2
...
)
[1] => 2 => Array
(
[0]=>1
[1]=>6
[2]=>1
[3]=>7
[4]=>4
)
[2] => 3 => Array
(
[0]=>5
[1]=>1
)
I can't submit without more information, so I will try to have more, while keeping it relevant.
I am using a form with multiple checkboxes that are assigned to ID's in a sql database. They are all listed, and are tied back to the record that will be updated by the check/uncheck of the box.
I'm attempting to add a picture for a visual reference.
