- substr: documentation ( source)
- var_dump: documentation ( source)
- strpos: documentation ( source)
- strrpos: documentation ( source)
<?php
$params = "test;colorgroup-b;test;abc";
var_dump(string_includes("group", $params)); //outputs: colorgroup-b
function string_includes($needle, $haystack) {
$needlePosition = strpos($haystack, $needle);
if ($needlePosition === false) {
return false;
}
$needleEndPosition = strpos($haystack, ';', $needlePosition);
if ($needleEndPosition !== false) {
$haystack = substr($haystack, 0, $needleEndPosition);
}
$delimiterPosition = strrpos($haystack, ';');
if ($delimiterPosition === false) {
return $haystack;
}
return substr($haystack, $delimiterPosition + 1);
}