Matter has been resolved. For some reason the css classes and the formatting are showing as intended now(the classes from the the 'ul' element).
For reference/suggestions I am updating my latest changes. I am using bootstrap 3 for this project
<div class= "collapse navbar-collapse navbar-ex1-collapse">
<ul >
<?php
$filename=str_replace (array("/","."), "", $_SERVER["PHP_SELF"]);
$content_array=["/Dashboard/", "/Categories/", "/Comments/", "/Profile/"];
foreach ($content_array as $value) {
if (preg_match($value,$filename) == true) {
$url=trim($value,"/");
echo "<li class='active'>
<a href='/cms/admin/{$url}.php'>{$url}</a>
</li>";
} else {
$url=trim($value,"/");
echo "<li> <a href='/cms/admin/{$url}.php'>{$url}</a></li>;
}
}
?>
</ul>
</div>
CodePudding user response:
<!--Ther's missing = in div " in variable assignment ) in if condition please check below code -->
<div class = "collapse navbar-collapse navbar-ex1-collapse">
<ul class = "nav navbar-nav side-nav">
<?php
$filename=str_replace (array('/','.'), '', $_SERVER["PHP_SELF"]);
$content_array=['/Dashboard/','/Catgegories/','/Comments/','/Profile/'];
foreach ($content_array as $value) {
if (preg_match($value,$filename) == true) {
echo "<li class='active'> {$value} </li>";
} else {
echo "<li> {$value} </li>";
}
}
?>
</ul>
</div>
CodePudding user response:
Yo have a lot of missing characters on your code Missing " on line 1, 25 and 33.
So, instead of == true you can clean the code. Just negate the condition like this:
<div >
<ul >
<?php
$filename = str_replace(["/", "."], "", $_SERVER["PHP_SELF"]);
$content_array = ["/Dashboard/", "/Catgegories/", "/Comments/", "/Profile/"];
foreach ($content_array as $value) {
if (!preg_match($value, $filename)) {
echo "<li class='active'> {$value} </li>";
} else {
echo "<li> {$value} </li>";
}
}
?>
</ul>
</div>