Harun Or Rashid Harun Or Rashid - 12 days ago 5
PHP Question

PHP Array variable Declare as alias

I will declare an array just once. Value would like to call again and again as the key alias. please any one can help me?
example:

I have :

<?php
$id = $profile[0]->id;
$roll = $profile[0]->roll;
$photo = $profile[0]->photo;
$active = $profile[0]->active;
?>


I neeed :

<?php
$var as $profile[0];
$id = $var->id;
$roll = $var->roll;
$photo = $var->photo;
$active = $var->active;
?>


It can be done with foreach () . However, I would like to work on Alias.
i need any good idea..

Answer

I think you can try this

    <?php
    // this line you can try
    $var = array();

    // your code
    $var = $profile[0];
    $id =  $var->id;
    $roll = $var->roll;
    $photo = $var->photo;
    $active = $var->active;
    ?>