PHP PHP - 4 months ago 5x
PHP Question

how to implode this pattern to array?

i want implode this txt pattern to Multidimensional Arrays and echo array into table

My pattern :<


i want echo this pattern like this (dont show website address)

Group1: john-jack-jorge

Group2: Ivan-Dan-Ted


Try this:

$str = "group1&john,]jack,]jorge,^group2&Ivan,]Dan,]Ted,^";

$str = trim($str, "^");
$groups = explode("^", $str);

foreach($groups as $val){
    $group = ucfirst(explode("&", $val)[0]);
    $arr = explode("]", explode("&", $val)[1]);
    $name = array();
    foreach($arr as $v)
        $name[] = explode(",", $v)[0];
    $name = implode("-", $name);
    echo $group.": ".$name."<br/>";