Reading your code, BahaediniParseRoute()
function, first you assign $segments[0]
to 'items', then you try to explode it and read $year
from it... it's returning '0' because you're casting $year
as int, but it contains 'items'.
Try removing the casts and var_dump($segments) before you assign it 'items' (which makes little sense anyways, why set it and then test it in a conditional loop? you know $segments[0]='items'
so what's the point of switch ... case 'items'
?