how to call a array variable in php code example

Example 1: 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 2: how to store array in variable php

$something = array(
    'http://www.marleenvanlook.be/admin.php',
    'http://www.marleenvanlook.be/checklogin.php',
    'http://www.marleenvanlook.be/checkupload.php',
    'http://www.marleenvanlook.be/contact.php',
);

foreach($something as $key => $value) {
    $key = 'something' . $key;
    $$key = $value;

    // OR (condensed version)
    // ${"something{$key}"} = $value;
}

echo $something2;
// http://www.marleenvanlook.be/checkupload.php

Tags:

Php Example