$ Str = 'Array 1, array 2, array 3, array 4 ';
$ Array = explode (',', $ str); // Save the regular string to an array
The explode () function separates strings into arrays.
Syntax
Explode (separator, string, limit) parameter description
Separator is required. Specifies where to split the string.
String is required. The string to be split.
Limit is optional. Specifies the maximum number of returned array elements.
$ Array = array_diff ($ array, array ('Array 2'); // delete an array item with the specified value
The array_diff () function compares two or more arrays. If the key or value in the first array does not appear in the second array, returns the key and value that does not appear in the second array in the form of an array.
Syntax
Syntax
Array_diff (array1, array2, array3 ...)
Parameter
Parameter description
Description
Array1 required. the first array is the array that the others will be compared
Required parameter. Specify the first benchmark array for comparison
Array2 required. an array to be compared with the first array
Required parameter. Specify the second array to be compared with the first array
Array3 optional. an array to be compared with the first array
Optional. Specifies the third array compared to the first array
$ Str = implode (',', $ array); // Save the array as a regular string
The implode () function combines array elements into a string.
Syntax
Implode (separator, array) parameter description
Optional. Specifies the content to be placed between array elements. The default value is "" (null string ).
Array is required. Array to be combined as a string.
Description
Although the separator parameter is optional. However, we recommend that you use two parameters for backward compatibility.
Echo $ str;