sesión de matriz

<?php
$my_arr = array('Saumya', 'Nikita', 'Upasana', 'Dyana');
// use array_push to add 3 elements to end of $my_arr
$new_num = array_push($my_arr, 'Adhikar', 'sanjay', 'Puspendra', 'Mukesh');
// inspect return value of array_push
echo $new_num;
print_r($my_arr);
?>

//my ex

$id = $_GET['PId'];
                                // $cartArray = array(
                                  
                                // );
                               // array_push($cartArray, $id);
                                session_start();

                            // $_SESSION["cart"] = $cartArray;
                             $_SESSION['cart'][] = $id;

                             header("Content-type:application/json");
                             echo json_encode($_SESSION["cart"]);
SmilingG