Reputation: 3695
So I have a simple variable that detects my /en/ or /sp/ sub folders in my site and puts those letters into my html class - right now I am just saying if the page isnt intro than echo 'en', how can I detect whether or not $page contains 'en', or 'sp' - basically on the english part of my site I want <html class="home en"
and the spanish side <html class="home sp"
$page = $_SERVER['REQUEST_URI'];
$page = str_replace('/', '', $page);
$page = str_replace('.php', '', $page);
$page = str_replace('?s=', '', $page);
$page = str_replace('en', '', $page);
$page = str_replace('sp', '', $page);
$page = $page ? $page : 'intro';
<html class="<?php echo $page ; if($page !== 'intro')echo ' en'; ?>">
Upvotes: 0
Views: 92
Reputation: 11112
You can detect this with strpos or stripos function. More about it in the PHP manual: http://si.php.net/manual/en/function.strpos.php
$isSpanish = stripos ($page, "/sp/");
if ($isSpanish !== FALSE)
{
// Logic here
}
Upvotes: 1