- array_map: documentation ( source)
- substr_count: documentation ( source)
- var_dump: documentation ( source)
- array_chunk: documentation ( source)
- implode: documentation ( source)
- explode: documentation ( source)
<?php
$string = 'asd/trara/bebe';
if (substr_count($string, '/') < 2) {
$split = explode('/', $string);
} else {
$split = array_map(
function($value) {
return implode('/', $value);
},
array_chunk(explode('/', $string), 2)
);
}
return var_dump($split);