fork download
  1. <?php
  2.  
  3. $path = 'file:\/\/\/specs\/operators.json#\/definitions\/number';
  4. $path = preg_quote($path);
  5.  
  6.  
  7. $jsonString = '{"type":"object","properties":{"id":{"$ref":"file:\/\/\/specs\/operators.json#\/definitions\/number","description":"описание"}';
  8. preg_match('~("\$ref":"'.$path.'")~', $jsonString, $match);
  9.  
  10. var_export($match);
  11.  
Success #stdin #stdout 0.02s 24520KB
stdin
Standard input is empty
stdout
array (
  0 => '"$ref":"file:\\/\\/\\/specs\\/operators.json#\\/definitions\\/number"',
  1 => '"$ref":"file:\\/\\/\\/specs\\/operators.json#\\/definitions\\/number"',
)