How to Remove Array Double Quotes in PHP?

03-Apr-2023

.

Admin

How to Remove Array Double Quotes in PHP?

Hi Dev,

In this article, we will discuss how to remove array double quotes in php. we can remove the array double quotes by using the str_replace() function. this function is check if how to remove array double quotes in php.

There are example to check if how to remove array double quotes in php. in this example, we will use to json_encode(), rtrim() and str_replace() function to check if how to remove array double quotes in php. so let's the following example with output.

Example 1:


index.php

<?php

foreach($location_total_n_4 as $u=> $v)

{

$final_location_total_4 .= "[".$u.",".$v."],";

}

$final_value = json_encode(array(

"location"=> rtrim($final_location_total_4,',')

));

echo str_replace(']"',']',str_replace('"[',"[",$final_value));

?>

Output:

{"location":""}

I hope it could help you...

#PHP