PHP show if with different categories array or variable? -
having problems here, think overlooking simple...
i have cms have multiple categories.
how create variable or array has included categories groups want use in show if statement ??
so example:
<?php $catsrow = array( 'cat_1' => '41','46','62', 'cat_2' => '41','45','63', 'cat_3' => '41','43','65' ); ?> <?php if (catsrow[0] || catsrow[1] || catsrow[2]) == ($row_detailrs1['category']) { echo 'do work' } else { ?>
thanks in advance!!
i guess asking is, how compare array multiple groups inside. need compare different grouped categories..
like $catsarray = array(cat_1 => '2,3,4' , cat_2 => '5,6,7' , cat_3 => '8,9,10')
if $row['cat_from_page'] == $catsarray (any of groups) show { }
????
you may need explode parts of array
kinda $parts = explode(',' , $cat);
http://php.net/manual/en/function.explode.php
but need implode whole thing 1 array
like implode (',', $parts);
Comments
Post a Comment