Maybe something like this - for php5, although I've included a php4 str_split() function for anyone who might need it;
PHP Code:
<?php
// php4 version of php5 native str_split() function
// uncomment if required
/*
function str_split($string, $length=1) {
$string_array = explode("\r\n", chunk_split($string, $length));
return $string_array;
}
*/
$year = "1922192319241925";
$yearcheck = "1923";
$array = str_split($year, 4); // split $year at every 4th character
$yr = array($array[0], $array[1], $array[2], $array[3]);
if (in_array($yearcheck, $yr)) {
echo "Found $yearcheck";
}
?>
This works on the assumption that $year is always formatted as 4 concatenated years, with each year consisting of 4 numbers (although you could extend the $yr array() with more values as required).
Bookmarks