PHP preg-split text-string telephone-numbers -


please me following problem:

    $my_string = 'here text , number: +43 (0) 123 456 - 78 ,      more text , different number + 43(0) 1234/ 567-789 ,      final text'; 

what need this:

array (     [0] => here text , number:      [1] => +43 (0) 123 456 - 78      [2] => , more text , different number      [3] => + 43(0) 1234/ 567-789      [4] => , final text   ) 

and final output :

<span> here text , number: <a href="tel:+43 123 456 78">+43 (0) 123 456 - 78</a> , more text , different number <a href="tel:+43 1234 567 789">+ 43(0) 1234/ 567-789</a> , final text </span> 

thanks helping! till.

the preg_replace job you. adapt regex on first parameter following this sintax more variations.

<?php  $my_string = 'here text , number: +43 (0) 123 456 - 78 ,     more text , different number + 43(0) 1234/ 567-789 ,     final text';  $output = preg_replace("/(\+\s*([0-9]+)\s*\(\s*([0-9]+)\s*\)\s*([0-9]+)[ \/-]+([0-9]+)[ \/-]+([0-9]+))/","<a href=\"tel:+$2 $4 $5 $6\">$1</a>",$my_string);  var_dump($output); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -