Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

string array to array of word

Tags:

php

mysql

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

like image 528
Shimul Chowdhury Avatar asked Dec 03 '25 04:12

Shimul Chowdhury


1 Answers

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.

like image 130
Kinshuk Lahiri Avatar answered Dec 05 '25 20:12

Kinshuk Lahiri