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

前端 未结 10 1663
失恋的感觉
失恋的感觉 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 11:48

    Try explode:

    $myString = "9,admin@example.com,8";
    $myArray = explode(',', $myString);
    print_r($myArray);
    

    Output :

    Array
    (
        [0] => 9
        [1] => admin@example.com
        [2] => 8
    )
    

提交回复
热议问题