Home » » Create variable at runtime in php

Create variable at runtime in php

Written By Unknown on Senin, 16 Desember 2013 | 01.36

Hey ... Today we are going to create variable at runtime from an array;
I have declared an array named $arr and i am iteration array using foreach loop
and for each element creating a variable using   $$ar .
And at last i am printing the created variables.

<?php
$arr=array("1"=>"abc","2"=>"def");
echo "<pre>";
print_r($arr);
foreach($arr as $ar){
   
    $$ar="success:".$ar;
}
echo $abc;
echo "<br/>";
echo $def;

?>


Run the above example , to understand more ...
Share this article :

Posting Komentar

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Kumpulan Kata Broadcast Blackberry - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger