I want to realize that when choosing a page the active menu would change.

There is a URL

/service/type/office_cleaning 

How to check if the /service line is in the /service/type/office_cleaning in php

1 answer 1

 $str = "/service/type/office_cleaning"; $sch = "/service"; if(stristr($str, $sch)):// Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ строку, рСгистронСзависима echo "$sch in string \r\n"; endif; if(strstr($str, $sch)):// Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ строку, рСгистрозависима echo "$sch in string \r\n"; endif; if(false !== stripos($str, $sch)):// Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ ΠΏΠΎΠ·ΠΈΡ†ΠΈΡŽ подстроки ΠΈΠ»ΠΈ false, рСгистронСзависима print_r('Π²Ρ…ΠΎΠΆΠ΄Π΅Π½ΠΈΠ΅ строки: ' . stripos($str, $sch) . "\r\n"); endif; if(false !== strpos($str, $sch)):// Π²ΠΎΠ·Π²Ρ€Π°Ρ‰Π°Π΅Ρ‚ ΠΏΠΎΠ·ΠΈΡ†ΠΈΡŽ подстроки, рСгистрозависима echo 'Π²Ρ…ΠΎΠΆΠ΄Π΅Π½ΠΈΠ΅ строки: ' . strpos($str, $sch) . "\r\n"; endif; if(false !== preg_match('/\$str/', $sch)):// провСряСт ΠΏΠΎ regex echo 'соотвСтствиС строки: ' . preg_match('/\$str/', $sch) . "\r\n"; endif; 

And there who knows how many ways.