Skip to content

Instantly share code, notes, and snippets.

@andronex
Created January 29, 2019 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andronex/a16ca133fc8471b48f3b645bab91b457 to your computer and use it in GitHub Desktop.
Save andronex/a16ca133fc8471b48f3b645bab91b457 to your computer and use it in GitHub Desktop.
Замена n-ого значения на что-то отличное от других замен
<?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