I have a string 33#math#indonesia#Primary 2, and want to be separated into like this 33,math,indonesia,primary 2 into four parts
Asked
Active
Viewed 52 times
-2

Muhamad Rahmat Setiawan
- 397
- 1
- 8
- 24
-
$stringParts = explode('#','33#math#indonesia#Primary 2'); this will return string parts into array seperated with # – Ajith Dec 03 '19 at 07:41
3 Answers
1
Use can also use implode and explode
$a = '33#math#indonesia#Primary 2';
$b = explode('#', $a);
$c = implode(',', $b);
print_r($c);
33,math,indonesia,Primary 2

Swetha Sekar
- 237
- 1
- 9
0
use explode()
$array = explode('#',$string);
print_r($array);
Output:- https://3v4l.org/uCPY0
if you want to add ,
instead of #
then use str_replace()
echo $string = str_replace('#',',',$string);
Output:- https://3v4l.org/8Mm08

Alive to die - Anant
- 70,531
- 10
- 51
- 98