It's free and you have access to premium codes!
Welcome back! Please login to your account.
Don't worry, we'll send you a message to help you to recover your acount.
Please check your email for instructions to activate your account.
Written by 29 December 2012
You know that the PHP finding functions (str_pos, strrpos and etc) just finds one matched string. This short script shows how to find all matched strings. It also highlights the found items.
<!-- this script is provided by https://www.phpfreecode.com coded by: Kerixa Inc. -->
<!-- This Script is from www.phpfreecpde.com, Coded by: Kerixa Inc-->
<?php
$txt='1mk23mk4mk56mmk67mkk';
$find='mk';
echo 'The search expression is found at <br>';
$a=-1;
while(is_numeric($a)){
$a++;
$a= strpos($txt,$find,$a);
if (is_numeric($a)) echo $a.'<br>';
}
echo 'characters.<br><br>';
$replace="<span style='background-color: #EEEE88'>$find</span>";
echo str_replace($find,$replace,$txt);
?>
<div style="text-align: left">
<br>
<font face="Tahoma">
<span style="font-size: 8pt; text-decoration: none"><a target="_blank" href="http://www.phpfreecode.com/">
PHP Free Code</a></span></font>
</div>
<a target='_blank' href='https://www.phpfreecode.com' style='font-size: 8pt; text-decoration: none'>Php Best Codes</a>
Comments
Here you can leave us commments. Let us know what you think about this code tutorial!