Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php session array

 session_start();
 $_SESSION['name_here'] = $your_array;
Comment

session array

<?php

//Start your session.
session_start();

//Add a product ID to our cart session variable.
$_SESSION['cart'][] = 2787376;

//Dump it out for example purposes.
var_dump($_SESSION);


//how to access it
<?php

//Start your session.
session_start();

//Make sure that the session variable actually exists!
if(isset($_SESSION['cart'])){
    //Loop through it like any other array.
    foreach($_SESSION['cart'] as $productId){
        //Print out the product ID.
        echo $productId, '<br>';
    }
}
Comment

array session

<?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"]);
Comment

PREVIOUS NEXT
Code Example
Php :: php select using prepared statements 
Php :: laravel datatable render html 
Php :: custom fields wordpress 
Php :: cron job every 5 minutes wordpress 
Php :: preg_split 
Php :: determine if file is empty in php 
Php :: php get last day of month 
Php :: how to run php in js 
Php :: How to Auto Backup Mysql Database Using PHP Script 
Php :: php split by 
Php :: laravel when query 
Php :: resize image using intervention laravel and save 
Php :: PHP rtrim — Strip whitespace (or other characters) from the end of a string 
Php :: delay queue laravel 
Php :: sanctum laravel 
Php :: laravel one to many relationship 
Php :: class name laravel 
Php :: what is cors in laravel 
Php :: how to access array using key in php 
Php :: test php code online free 
Php :: loginByUserID in conrete 
Php :: how to add x-xss-protection header 
Php :: get url parameter laravel 5.2 constructor 
Php :: wp wc archive product page template 
Php :: jwt return true 
Php :: php mysql update all rows in table random values 
Php :: laravel list all tbales 
Php :: Laravel save without an event 
Php :: Get a list of the arrays keys 
Php :: Redirect User To Different Page 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =