Answers for "how to store array in variable php"

PHP
0

assign array to variable php

$info = array('coffee', 'brown', 'caffeine');

// Listing all the variables
list($drink, $color, $power) = $info;
echo "$drink is $color and $power makes it special.\n";

// Listing some of them
list($drink, , $power) = $info;
echo "$drink has $power.\n";

// Or let's skip to only the third one
list( , , $power) = $info;
echo "I need $power!\n";

// list() doesn't work with strings
list($bar) = "abcde";
var_dump($bar); // NULL
Posted by: Guest on July-22-2020
0

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
Posted by: Guest on October-20-2020
0

how to store array in variable php

$data = array(
    'something1',
    'something2',
    'something3',
);
extract($data, EXTR_PREFIX_ALL, 'var');
echo $var0; //Output something1
Posted by: Guest on October-20-2020
0

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
Posted by: Guest on October-20-2020

Code answers related to "how to store array in variable php"

Browse Popular Code Answers by Language