Created
January 29, 2019 10:58
-
-
Save andronex/a16ca133fc8471b48f3b645bab91b457 to your computer and use it in GitHub Desktop.
Замена n-ого значения на что-то отличное от других замен
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if($input){ | |
$count = 0; | |
if(!function_exists('rep_count')){ | |
function rep_count($matches) { | |
global $count; | |
$count++; | |
if($count == 2){ | |
return '<br><i class="fa fa-whatsapp"></i> '; | |
} | |
return '<br><i class="fa fa-phone"></i> '; | |
} | |
} | |
$out = preg_replace_callback('/,/', 'rep_count', $input); | |
$out = str_replace([',','(WhatsApp)'],['<br><i class="fa fa-phone"></i> ',''],$out); | |
return $out; | |
} | |
return; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment