I can not get this to work.
How do I change key [0]
to [id]
. In the below array ex. I want the [0] => 2
to look like [id] => 2
Array ex.:
Array
(
[pickup] => 2014/11/10 15:15
[tire_front] => tire_front
[service] => 4
[message] =>
[user] => 1
[0] => 2
)
My php script:
<?php
if (isset($_POST['rep_list'])) {
//insert database connect script here
$workCard = $_POST['rep_list'];
array_push($workCard, $id);
print_r($workCard) ."<br>";
}
else{
echo("errorrrrr");
}
?>
SOLVED
<?php
if (isset($_POST['rep_list'])) {
//insert database connect script here
$workCard = $_POST['rep_list'];
$workCard['id'] = $id;
print_r($workCard) ."<br>";
}
else{
echo("errorrrrr");
}
?>
You should not use
array_push
for thisIf it is already setted you can
unset($workCard[0])