replace every second comma of string using php -


i have string of displays this:

1235, 3, 1343, 5, 1234, 1 

i need replace every second comma semicolon

i.e.

1235, 3; 1343, 5; 1234, 1 

the string length different follow same pattern above i.e. digits comma space digits comma space, etc.

how can php? possible?

thanks.

try :

$str     = '1235, 3, 1343, 5, 1234, 1'; $res_str = array_chunk(explode(",",$str),2); foreach( $res_str &$val){    $val  = implode(",",$val); } echo implode(";",$res_str); 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -