to: repley at freemail dot it
the code works very well, but as i was trying to cut script names (e.g.: $_SERVER["SCRIPT_NAME"] => /index.php, cut the string at "/" and return "index.php") it returned nothing (false). i've modified your code and now it works also if the needle is the first char.
- regards from germany
<?php
function strxchr($haystack, $needle, $l_inclusive = 0, $r_inclusive = 0){
if(strrpos($haystack, $needle)){
$left = substr($haystack, 0, strrpos($haystack, $needle) + $l_inclusive);
$r_inclusive = ($r_inclusive == 0) ? 1 : 0;
$right = substr(strrchr($haystack, $needle), $r_inclusive);
return array($left, $right);
} else {
if(strrchr($haystack, $needle)) return array('', substr(strrchr($haystack, $needle), $r_inclusive));
else return false;
}
}
?>