Php - Find only one number in a string -


i have php script loads different ids , send them page on variable, separated coma:

.../page.php?items=12,13,43,17, 

i load mysql while loop table shows up, , need see if id of table item same adds style table row.

so did was:

$style = (strstr($_get['ids'], $segn['itemid'])) ? 'style="background:lightgreen;"' : '' ; <tr class="gradex" <?= $style ?> >; 

in case worked single numbers. in case have ids: 1, 2, 3 ... 12 , page request "page.php?items=12" ids '12', '1' , '2'.

i thought use explode(',' , $_get['ids']) guess goes long.

how ids? (i've no affinity whatsoever regexp...).

instead of:

strstr($_get['ids'], $segn['itemid']) 

you this:

in_array($segn['itemid'], explode(',',$_get['ids'])); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -