简体   繁体   中英

PHP define and echo result

How to define data from database if i have in database table this as result s,d,r,t ?

Here is the screen from table

http://i.imgur.com/9dK7T.png

I can do this if i have only s in database

if($func->data =='s') {echo "This is S";}

I need to define every letters in table and echo result, but how ? if i have more than one letters how i can do this?

This seems to be what you want:

$letters = explode(',', strtolower($func->data));

if (in_array('s', $letters)) echo 'This is S';
if (in_array('d', $letters)) echo 'This is D';
if (in_array('r', $letters)) echo 'This is R';
if (in_array('t', $letters)) echo 'This is T';
if (in_array('e', $letters)) echo 'This is E';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM