cut a string by a php delimiter

0

I need to cut words after ", " in PHP

I have something similar to this $string = "dato, dato, dato" , it's the same name only that is repeated.

    
asked by Arielperez 13.09.2018 в 14:52
source

1 answer

1

You can use explode to divide a string into several string. Description:

array explode ( string $delimiter , string $string [, int $limit = PHP_INT_MAX ] )
  • delimiter: The delimiting string.

  • string: The input string.

For example:

$string = 'dato1, dato2, dato3';
$datos = explode(", ", $string);
var_dump($datos);

Exit:

array(3) { [0]=> string(5) "dato1" [1]=> string(5) "dato2" [2]=> string(5) "dato3" }
    
answered by 13.09.2018 / 15:09
source