Avatar of Chris Andrews
Chris AndrewsFlag for United States of America

asked on 

pulling values out of arrays and into strings

I have an array like this:

print_r($GA); //provides these results

Array (
 [0] => Array ( [LABEL] => GAD ID [TYPE] => text [NAME] => GA_ID [VALUE] => 1707444616535 )
 [1] => Array ( [LABEL] => GAd 1 [TYPE] => text [NAME] => GA_1 [VALUE] => 6780673118 )
 [2] => Array ( [LABEL] => GAd 2 [TYPE] => text [NAME] => GA_2 [VALUE] => 3745034999 )
 )

I need to pull those VALUEs out as strings and have this :

$GA_ID = // the value of GA_ID
$GA_1 = // the value of GA_1
$GA_2 = // the value of GA_2

I'm not array-smart.  How is this done?

Thank you,                Chris

PHP

Avatar of undefined
Last Comment
OmniUnlimited
ASKER CERTIFIED SOLUTION
Avatar of OmniUnlimited
OmniUnlimited
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Chris Andrews
Chris Andrews
Flag of United States of America image

ASKER

ah, ok, then I proceed like this?

echo $newArray['GA_ID'];

that's what seems to work from some quick experimenting
Avatar of OmniUnlimited
OmniUnlimited
Flag of United States of America image

No.  You asked to have variables like this:

$GA_ID = // the value of GA_ID
$GA_1 = // the value of GA_1
$GA_2 = // the value of GA_2

and that's what I gave you.  If you echo the values you will get the following:

echo $GA_ID; // displays 1707444616535
echo $GA_1; // displays 6780673118
echo $GA_2; // displays 3745034999

Isn't this what you asked for?
Avatar of OmniUnlimited
OmniUnlimited
Flag of United States of America image

If you actually wanted it to be in the $newArray['GA_ID'] format, simply get rid of the extract statement.
Avatar of Chris Andrews
Chris Andrews
Flag of United States of America image

ASKER

Ah, sorry, I got confused somewhere, the first time I tested it didnt' seem to work, and type on my part perhaps -

You do have it exactly as needed  :)  

Thank you,

Chris
Avatar of OmniUnlimited
OmniUnlimited
Flag of United States of America image

You are welcome!  Best of luck to you on your project.
PHP
PHP

PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

125K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo