-6

My value is coming like this with two enters. please see below :

125

124

132

I am getting this value by php variable and want to get values with commas in new php variable.

i want like this 125,124,132

anyone have an idea for that please?

Ravi Varma
  • 145
  • 1
  • 1
  • 10

2 Answers2

0
$str = "125

124

132";

$str = str_replace("\r\n\r\n", ",", $str);
echo $str;

Try the above code. Please let know if this worked.

Biju P Dais
  • 131
  • 1
  • 12
-1

You can directly add commas between numbers using

number_format() function of PHP

<?php
  echo number_format("125124132")."<br>";
?>

Answer:- 125,124,132

Try the above given code and let me know if this worked.....