How to parse (extract) double quoted substrings from a string in PHP

2 Answers

0 votes
$s = 'PHP "HTML JavaScript" CSS';
 
preg_match('/"([^"]+)"/', $s, $arr);
    
echo $arr[1];   
  
/*
run:
   
HTML JavaScript
    
*/

 



answered Feb 6, 2017 by avibootz
0 votes
$s = 'PHP "HTML JavaScript" CSS';
 
preg_match_all('`"([^"]*)"`', $s, $arr);
    
echo $arr[1][0];   
  
/*
run:
   
HTML JavaScript
    
*/

 



answered Feb 6, 2017 by avibootz
...