Hướng dẫn how to convert comma separated string to array php? - làm thế nào để chuyển đổi chuỗi phân tách bằng dấu phẩy thành mảng php?

Xem thảo luận

Cải thiện bài viết

Lưu bài viết

  • Đọc
  • Bàn luận
  • Xem thảo luận

    Cải thiện bài viết

    Lưu bài viết

    Đọc

    Examples:

    Input : geeks,for,geeks
    Output : Array [ [0] => geeks [1] => for [2] => geeks ]
    
    Input : practice, code
    Output : Array [ [0] => practice [1] => code ]
    

    Bàn luận

    Cho một chuỗi dài cách nhau với dấu phân cách dấu phẩy. Nhiệm vụ là phân chia chuỗi đã cho với dấu phân cách dấu phẩy và lưu trữ kết quả trong một mảng. The explode[] function is an inbuilt function in PHP which is used to split a string in different strings. The explode[] function splits a string based on a string delimiter, i.e. it splits the string wherever the delimiter character occurs. This functions returns an array containing the strings formed by splitting the original string.
    Syntax:

    array explode[ separator, OriginalString, NoOfElements ]

    Sử dụng hàm explode [] hoặc preg_split [] để phân chia chuỗi trong PHP với dấu phân cách đã cho. The preg_split[] function operates exactly like split[], except that regular expressions are accepted as input parameters for pattern.

    Syntax:

    array preg_split[ string $pattern, string 
    $subject [, int $limit = -1 [, int $flags = 0 ]] ]

    Example:

    Bài Viết Liên Quan

    Chủ Đề