<?php function extractWantedStuff($string) { $sections = explode('""', $string); foreach ($sections as $key => $section) { if ($key % 2 != 0) { $sections[$key] = str_replace(',', '', $section); } } return implode('""', $sections); } $fullstring = ',""Word1, Word2"" and another thing ,""Word3, Word4""'; echo extractWantedStuff($fullstring);
You have javascript disabled. You will not be able to edit any code.