Y.Hewa Y.Hewa - 9 months ago 40
PHP Question

remove character from php key value array

enter image description here

This is the array i have right now. I want to remove the random open bracket in the [0] => ["A100" and also the random close bracket in [4] => "B11"] ....I ve tried using :

foreach($list as $key=>$value)
**//its suppose to be the same array that is $list not a new array $array**

$list being the array that contains the pictured elements. It doesnt seem to remove the brackets.. Am I doing something wrong?

**UPDATE: **

Im getting the array from a localstorage sending it through post to another php where i catch the value and explode to a array called $list.

url: 'FactorAnalysis.php',
type: 'POST', // GET or POST
data: {data: localStorage.getItem('reportArray')}, // will be in $_POST on PHP side
success: function(data) { // data is the response from your php script
// This function is called if your AJAX query was successful
alert("Response is"+ data);
error: function() {
// This callback is called if your AJAX query has failed


the localStorage outputted to a div shows me :
enter image description here

so here im sending the data through a ajax call:

$list = array();

$list = explode(',',$_POST['data']);

^ then in another php (FactorAnalysis.php) i get the array and explode to array $list.

Answer Source

Try this

 $list = json_decode($_POST['data'], true);


$list = explode(',',$_POST['data']);