Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
After getting the array from a post, the array won't display the way I want.

After calling displeArray($key) from a submit form the function return me a array like this:
Array ( [return] => Array ( [product] => 6546 [users] => 4545 [activation_date] => 1363629173 [expiration_date] => 1426701173 [serial_status_id] => 1 [package_id] => 9999 ) )

But I want it to display into a good looking way, I had try foreach loop but no working.

function runVerifyKey($client)
{
$clients = verifyKey($client);
foreach($clients as $key => $value)
{
$generated .= $clients[$key] => $value;
echo $generated;
}
}

Doesn't work.
Posted
Updated 26-Apr-13 8:28am
v2

is this looks like better?
VB
Array
(
    [product] => 6546
    [users] => 4545
    [activation_date] => 1363629173
    [expiration_date] => 1426701173
    [serial_status_id] => 1
    [package_id] => 9999
)


PHP
$a=array('return'=> array( 'product'=> 6546,'users'=> 4545, 'activation_date'=> 1363629173 ,'expiration_date' => 1426701173,'serial_status_id'=> 1 ,'package_id' => 9999 ) );
print_r($a);
function change($a){
    foreach($a as $key=>$value){
        if(is_array($value)){
            foreach($value as $key1=>$value1){
                $b[$key1]=$value1;
            }
        }
    }
    return $b;
}

print_r(change($a));
 
Share this answer
 
v2
It should be

PHP
foreach($array as $key => $value)
{
$generated .= "\$array[$key] => $value.";
}


that is a multidimensional array not a single one.
 
Share this answer
 
v2
Comments
Yafa Su 26-Apr-13 14:28pm    
doesn't work everything disapear in the page.
Yafa Su 26-Apr-13 14:40pm    
didnt work everything disapear after I call that function
function runVerifyKey($client)
{
$clients = verifyKey($client);
foreach($clients as $key => $value)
{
$generated .= $clients[$key] => $value;
echo $generated;
}
}
Oso Oluwafemi Ebenezer 26-Apr-13 15:09pm    
Missed my eyes the first time... Your funtion is returning the multidimensional array inside of another array
Array([return]=>then the real array)
Oso Oluwafemi Ebenezer 26-Apr-13 15:19pm    
$r = $client['return']// to get out the real array form the returned array.

you can then do the eariler foreach on $r

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900