PHP funkce substr_compare()
06. 07. 2020Dostupnost ve verzích: PHP 5.0
Binary safe comparison of 2 strings from an offset, up to length characters
Parametry
Parametr | Datový typ | Výchozí hodnota | Poznámka |
---|---|---|---|
$main_str | string | The main string being compared. | |
$str | string | The secondary string being compared. | |
$offset | int | The start position for the comparison. If negative, it starts counting from the end of the string. | |
$length | int | null, | The length of the comparison. |
$case_insensitivity | bool | null | If case_insensitivity is true, comparison is case insensitive. |
Návratové hodnoty
int
< 0 if main_str from position offset is less than str, > 0 if it is greater than str, and 0 if they are equal. If offset is equal to or greater than the length of main_str or length is set and is less than 1, substr_compare prints a warning and returns false.
Další zdroje
https://php.net/manual/en/function.substr-compare.php
Jan Barášek Více o autorovi
Autor článku podniká jako fullstack senior developer v Praze. Spravuje 300 různě velkých webových projektů, fungujících dodnes. Během spolupráce nabral hluboké zkušenosti, které na tomto webu předává dál.
Rád vám pomůžu:
Kontakt Konzultace a služby Nabídka spolupráce