<?php
/**
* replace only the first occurance of str math
*
*/
function str_replace_first_only($from, $to, $content,$count)
{
$from = '/'.preg_quote($from, '/').'/';
return preg_replace($from, $to, $content, $count); // remove only first occurance
}
$patha = 'BIN/BIN/test.php';
$count = 1;
$pathb = str_replace_first_only('BIN', 'SYSTEM', $patha, $count);
echo $pathb;
?>
preferences:
24.56 ms | 405 KiB | 5 Q