Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
How to remove one characters of an array with json_encode and mysql

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(',', ' ');
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!