convert to array a value of a cell

i have a value from a database field named "possible status" like this:

01,02,03,04

I need to convert this to an array and then i need a code to find if a value exist in this array,

any idea?
LVL 1
joyacv2Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris Harte2015 Top Expert (Most Article Points)Commented:
This works
$my_array = explode(",", "01,02,03,04");

print_r($my_array);

$key = array_search ('02', $my_array);
echo "<br /> the key is ". $key;

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chris Harte2015 Top Expert (Most Article Points)Commented:
Better yet, use in_array() instead of array_search. Identical to the above but will just return true or false rather than the key.
Ray PaseurCommented:
+1 for using in_array() instead of array_search().  Because PHP is loosely typed, an element found at position zero, would cause array_search() to return a value of zero, which is one of the "falsy" values that is often misinterpreted as equal (but not identical) to false.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.