php - replace comma between double quotes using preg_replace -


i have csv file this

number,name,ug college,ug university,pg college,pg university 1100225,lakshmin,pkrrrr college,"pkrrrrr university, choice",nandhaaaaa,"nandhaa university, kumali" 

while reading file want replace comma inside double quotes .

thanks in advance .

$string = '1100225,lakshmin,pkrrrr college,"pkrrrrr university, choice",nandhaaaaa,"nandhaa university, kumali"';  $string = preg_replace_callback(         '|"[^"]+"|',         create_function(             // single quotes essential here,             // or alternative escape $ \$             '$matches',             'return str_replace(\',\',\'*comma*\',$matches[0]);'         ),$string ); $array = explode(',',$string); $array = str_replace('*comma*',',',$array); print_r($array);        exit; 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -