echo($menuVal['icon']);
/* if($menuVal['icon'] !== 'fa-dashboard' ){
$menuHTML .= '<span class="ico fa fa-fw fa-chevron-right"></span>';
}*/
$cont=strcmp($menuVal["icon"],"fa-dashboard");
echo($cont);
if((strcmp($menuVal["icon"],"fa-dashboard")) != 0 ){
$menuHTML .= '<span class="ico fa fa-fw fa-chevron-right"></span>';
}
in this code i'm trying to print the icon using php if it value is not equal to fa-dashboard,i think strcmp
will produce an output zero if inputs are equal,but in this code strcmp is producing an output of 243 when both strings are equal and the if
condition is worked when put 243 instead of 0.
i added the output obtained on below,i'm also checked the value of $menuVal['icon']
to check what it prints,
fa-dashboard 243fa-globe 768fa-puzzle-piece 3072fa-pie-chart
3072fa-gears 768fa-anchor -768
is there any error in this code?how can i fix that? any help will get appreciated..........!!!
Your checking if the entire string equals fa-dashboard which is not.
If fa-dashboard is always the first item you can use strncmp to match only the first n characters.
int strncmp ( string $str1 , string $str2 , int $len )
This function is similar to strcmp(), with the difference that you can specify the (upper limit of the) number of characters from each string to be used in the comparison.