I'm trying to use explode() with a result that is
stored in my database.
If I do something like this:
$str_text = 'blue, orange, green, red';
$arr_words = explode(',',$str_text);
print_r($arr_words);
I get the proper result which is--
Array ( [0] => blue [1] => orange [2] => green [3] => red )
but what I want to do is get the array value
from a field in my database which holds
the above color values and then explode the array values in the same way. This is what I am doing, but it doesn't work. Where am I going wrong?
<?PHP
$result = mysql_query("select * from table where color = '$color'") or die (mysql_error());
while($a_row=mysql_fetch_assoc($result)) {
$str_text = '$a_row["color"]';
$arr_words = explode(',',$str_text);
print_r($arr_words);
}
?>