Home > Enterprise >  Laravel Array Conversion of array enclose to bracker
Laravel Array Conversion of array enclose to bracker

Time:12-15

how can i convert this array

array:1 [
          0 => "Cambodia, Japan" 
]

into like this $destinations = ['Cambodia','Japan'];

CodePudding user response:

Simply use the PHP explode() function.

$array = [ "Cambodia, Japan" ];
$destinations = explode(', ', $array[0]);
  • Related