how to store data in array in php code example

Example 1: array in php

<?php

$cars = array("Maserati", "Porsche", "BMW");

echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";

?>

Example 2: how to store array in variable php

$myArray = array("http://www.marleenvanlook.be/admin.php","http://www.marleenvanlook.be/checklogin.php","etc");

$i = 0;
foreach($myArray as $value){
    ${'something'.$i} = $value;
    $i++;
    }

echo $something0; //http://www.marleenvanlook.be/admin.php

Example 3: how to store array in variable php

$data = array(
    'something1',
    'something2',
    'something3',
);
extract($data, EXTR_PREFIX_ALL, 'var');
echo $var0; //Output something1

Tags:

Php Example