Iterate through array and get pull out specific values

Hello,

I’m trying to pull 2 specific values from the array below, the “name” & the “tmp_name”:

array(5) { [“name”]=> array(1) { [0]=> string(10) “orange.jpg” } [“type”]=> array(1) { [0]=> string(10) “image/jpeg” } [“tmp_name”]=> array(1) { [0]=> string(14) “/tmp/phpzVAl3n” } [“error”]=> array(1) { [0]=> int(0) } [“size”]=> array(1) { [0]=> int(13748) } }

I tried different variations with the foreach loop and I’m not getting the results i’m looking to get.
any ideas on how i can pull the 2 values out? in this case $v1= “orange.jpg” and $v2=“/tmp/phpzVAl3n”


foreach($testArray as $key1 => $value)
{	if(is_array($value)) 
	{	foreach ($value as $key2 => $val2) 
		{	echo $key1 ." ". $key2. " ". $val2; }  
	}
}

Is the array shown still in the $_FILES array or has it been moved out of the $_FILES array?

$v1 = $array[‘name’][0];
$v2 = $array[‘tmp_name’][0];
… you… really dont need to loop anything here?

Thanks for the looking at my posting.

its moved into $testArray. having said that if you have a different idea I’m open to looking at it. it would take much to change my test code round.

Hi StarLion,
Thank you for the help.
I rewrote the code with your suggestion and still not able to get seprate the 2 specific values i need. I copy/pasted the rewrite and the results.
How can I just get the 2 values?


foreach($testArray as $key1 => $value)
{	 if(is_array($value)) 
	{   echo $valA = $testArray['name'][0];
            echo "<br>";
            echo $valB = $testArray['tmp_name'][0]; 				 
	}
}

resutls:
geo1.JPG
/tmp/phpvhk268geo1.JPG
/tmp/phpvhk268geo1.JPG
/tmp/phpvhk268geo1.JPG
/tmp/phpvhk268geo1.JPG
/tmp/phpvhk268

It’s impossible for you to have gotten these results with just the code you pasted there, unless you’re looping through this whole code block more than once. the value of $testArray[‘name’][0] would not change. Please show us the WHOLE code.