I develop a drawing system and I have a little problem, I have one var into json_encode because I use MySQL and the line of result is:
30,Richard,Léa
29,Brown,Mike
I want to delete all commas of the line of result, but it's impossible.
This is my code:
$query = "SELECT id, nom, prénom FROM membres";
$result = mysqli_query($mysqli, $query);
$products = []; // new array
while($product = mysqli_fetch_array($result, MYSQLI_NUM)) {
$products[] = $product ; // push into array
}
var names = <?php echo json_encode($products) ?>;
When I want to use the replace function, I have nothing into my var "names" and no result to print.
var x;
for(x = 0; x < 10; x++){
names[x] = names[x].replace(',', ' ');
}