This is my array:
Array(
[Priority] => 194.49
[Xpresspost] => 147.49
[Expedited] => 48.57
[Regular] => 48.57
)
I want to show my array like this:
'Priority'=> '194.49','Xpresspost'=>'40','Expedited'=> '48.57','Regular'=>'48.57'
This is my array:
Array(
[Priority] => 194.49
[Xpresspost] => 147.49
[Expedited] => 48.57
[Regular] => 48.57
)
I want to show my array like this:
'Priority'=> '194.49','Xpresspost'=>'40','Expedited'=> '48.57','Regular'=>'48.57'
If you want your array to be printed in a single line like that you could use:
$array = array(
'Priority' => 194.49,
'Xpresspost' => 147.49,
'Expedited' => 48.57,
'Regular' => 48.57
);
$output = array();
foreach($array as $key => $value) {
$output[] = " '$key' => '$value'";
}
echo implode(',', $output);
foreach($array as $key => $value) {$array[$key] = "'$value'";} then return the array itself as return $array.