note 53065 deleted from function.substr-compare by nlopess
| From: | nlopess@php.net | Date: | Sat, 14 Jan 2006 20:44:16 +0000 |
| Subject: | note 53065 deleted from function.substr-compare by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-101761@lists.php.net to get a copy of this message | ||
Note Submitter: sleek
----
PHP4 version for those who need it:
<?php
if (!function_exists('substr_compare')) {
function substr_compare($main_str, $str, $offset, $length = NULL, $case_insensitivity = false) {
$offset = (int) $offset;
if ($offset >= strlen($main_str)) {
trigger_error('The start position cannot exceed initial string length.',
E_USER_WARNING);
return;
}
if (is_int($length)) {
$main_substr = substr($main_str, $offset, $length);
} else {
$main_substr = substr($main_str, $offset);
}
if ($case_insensitivity === true) {
return strcasecmp($main_substr, $str);
}
return strcmp($main_substr, $str);
}
}