How can I split a delimited string into an array in PHP?

前端 未结 10 1593
失恋的感觉
失恋的感觉 2020-11-21 11:11

I need to split my string input into an array at the commas.

How can I go about accomplishing this?

Input:

9,admin@example.com,8
10条回答
  •  南笙
    南笙 (楼主)
    2020-11-21 12:10

    Code:

    $string = "9,admin@example.com,8";
    
    $array  = explode(",", $string);
    
    print_r($array);
    
    $no = 1;
    foreach ($array as $line) {
        echo $no . ". " . $line . PHP_EOL;
        $no++;
    };
    

    Online:

    body, html, iframe { 
      width: 100% ;
      height: 100% ;
      overflow: hidden ;
    }

提交回复
热议问题