Chris Andrews
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
$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?
If you actually wanted it to be in the $newArray['GA_ID'] format, simply get rid of the extract statement.
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
You do have it exactly as needed :)
Thank you,
Chris
You are welcome! Best of luck to you on your project.
ASKER
echo $newArray['GA_ID'];
that's what seems to work from some quick experimenting