i have data in my mysql database "Service,House Worker" (without ""), when i access my data from the database i found (Service,House Worker) as it is, when i try to convert with (var_dump(explode(',',($CheckBoxAnswer)));) it then its return following :
array(1) { [0]=> string(26) "Service,House Worker" }
but i want something similar:
array(1)
(
[0] => string(7) "Service"
[1] => string(13) "House Worker"
)
$CheckBoxAnswer is contain data i pulled from mysql.
i tried with var_dump(explode(',',($CheckBoxAnswer)));
but its not working
Try this:
var_dump(explode(',',($CheckBoxAnswer[0])));
You are tring to explode an array into an another array. You need to specify the string instead.
First you need to trim $CheckBoxAnswer
Because by using var_dump giving string length 26 instead of 20
Then after use string replace
str_replace('/','',$CheckBoxAnswer);
After that try to use var_dump(explode(',',($CheckBoxAnswer)));