How to convert an array to PHP variables ?

Hi,

I would like to request an assistant.

I have the script as follows :

$package_array = get_hosting($cpid);
print_r($package_array);

It produce the following array :

Array
(
    [hid] => 2
    [hownerid] => admin
    [huser] => dsg462
    [hpass] => dsfserw354
    [horder_id] =>
    [hpackage_id] => 211436549
    [hplan] => Linux-Standard-Plan
    [hterm] => Annually
    [hstatus] => 1
    [hserver] => Server8
    [hfqdn] =>
    [serverip] =>
    [hip] => 112.8.25.94
    [hdns1] => dns60.domain.com
    [hdns2] => dns61.domain.com
    [hdns3] =>
    [hdns4] =>
    [hdomain] => shamutest.com
    [hrenew_date] => 09-29-2014
    [hstart_date] => 09-29-2013
    [hrenewed_on] => 09-29-2013
    [hlast_invoice] =>
    [hprice_override] =>
    [hprice_override_expires] =>
)

May i know how to convert this array to variables ?

Eg :

echo "$hownerid"; , will give output as :

admin


Appreciates any assistant.


Thank you.
LVL 2
Shamsul KamalJunior TechAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
<?php echo $package_array['hownerid'];
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ray PaseurCommented:
You can assign the array indexes to variables with extract() but there are a variety of reasons why that is a risky programming practice.  It's smarter to just address the array elements directly and not risk the proliferation of variables into your symbol table.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.