Page 1 of 1

Read from DataBase using PHP

Posted: Tue Jan 09, 2007 6:37 pm
by ykarmi
Hey guys,
I wanted to know what code I should use to read from a database cell that has values separated by a comma?
Say I have the values 1,3,5 and now I want to check if 1 exists withing the string then $one = true for example. How do I verify if the number 1 exists in a certain string (from a database, if that even matters)?
Thanks a lot!
Yuval :D

Posted: Tue Jan 09, 2007 6:48 pm
by impulse()
I'd be using

Code: Select all

str_split
or

Code: Select all

explode

Posted: Tue Jan 09, 2007 8:24 pm
by aaronhall
explode() by comma, and in_array() to check if a value exists

Thanks!

Posted: Tue Jan 09, 2007 9:47 pm
by ykarmi
Thank you guys, the both of you, you have been great help!
:D :D :D Yuval