-4
Как удалить значение из массива сеанса с помощью ссылки удаления в таблице.Удалить значение из массива сеанса
// в файл А
< ?php
$_SESSION['cart']['prices'][] = "1000";
$_SESSION['cart']['services'][] = "game 1";
$_SESSION['cart']['prices'][] = "2000";
$_SESSION['cart']['services'][] = "game 2";
$_SESSION['cart']['prices'][] = "3000";
$_SESSION['cart']['services'][] = "game 3";
$_SESSION['cart']['prices'][] = "4000";
$_SESSION['cart']['services'][] = "game 4";
?>
// в файле B
< table border="1">
< thead>
< th style="width: 450px; text-align:center;">Services< /th>
< th style="width: 450px; text-align:center;">Price< /th>
< th style="width: 450px; text-align:center;">Delete item< /th>
< /thead>
< tbody>
< ?php
foreach ($_SESSION['cart']['services'] as $key => $service) {
echo "< tr>< td>".$service."< /td>< td style='text-align:center;'>".$_SESSION['cart']['prices'][$key]."< /td>< td>ckick to remove< /td>< /tr>";
}
?>
< /tbody>
< /table>
использование "снята с охраны() для пытаться? – Turtle
например 'unset ($ _ SESSION ['cart'] ['services']);' – davidkonrad
better 'unset ($ _ SESSION ['cart'] ['services'] [$ indexToRemove]);' – syck