Im running a loop to insert a column from csv file .The csv file contains a column with values like
India
srilanka
china taiwan
USA UK France
china japan
I split the column using preg_split function ,to split based on empty spaces
preg_split('/\s+/', $countries);
After splitting i get the output like this
Array
(
[0] => India
)
Array
(
[0] => srilanka
)
Array
(
[0] => USA
[1] => UK
[2] => France
)
Array
(
[0] => china
[1] => japan
)
each array if it contains more than one value it should append 2nd and third with opening and closing braces
I want to have final value as
india
srilanka
USA(UK France)
China(japan)