fork(2) download
  1. <?php
  2.  
  3. $text = 'Phone +1 (234) 345 6543 to obtain a free copy.';
  4. $pattern = '~(\+0?1\s)?\(?\d{3}\)?[\s.-]\d{3}[\s.-]\d{4}~';
  5. $replacement = '<a href="tel:$0">$0</a>';
  6. echo $text = preg_replace($pattern, $replacement, $text);
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
Phone <a href="tel:+1 (234) 345 6543">+1 (234) 345 6543</a> to obtain a free copy.