Hi Guys!

I cant find a way to show my data array the way i need it to be hope you can help me. i already tried using array_push(), json_encode() but still no result. basically what i am getting is like this

Array ( [0] => Array ( [name] => Boat + Cab [TOTAL] => 3 ) 
                [1] => Array ( [name] => Bus + Boat [TOTAL] => 41040 )
                [2] => Array ( [name] => Bus + Boat + Cab [TOTAL] => 840 ) 
                [3] => Array ( [name] => Bus Only [TOTAL] => 14343.75 ) 
                [4] => Array ( [name] => Door to Door [TOTAL] => 691073.75 ) )

But i need the data in this format

                    ['Boat + Cab', 3],
                    ['Bus + Boat', 41040],
                    ['BUS + BOAT', 1000],
                    ['Bus + Boat + Cab', 840]
                    ....etc

What should i do?

Thanks Neil,

Member Avatar for diafol

Seems like you want to get rid of the keys for some reason. All you need to do is do array_values() over the arrays you wish to strip of their keys.

$r = []
foreach($array as $element) $r[] = array_values($element);
$string = json_encode($r)
echo $string;

Hi Diafol!

Thanks for that but how can i remove the "" on the numbers?
[["Boat + Cab","3"],["Bus + Boat","41040"],["Bus + Boat + Cab","840"],["Bus Only","14343.75"],["Door to Door","674973.75"]]

the format should look like this.

[["Boat + Cab",3],["Bus + Boat",41040],["Bus + Boat + Cab",840],["Bus Only",14343.75],["Door to Door",674973.75]]

thanks

Hi never find got it already.thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.