Home > Article > Backend Development > How to forcefully convert an array in php
php method to forcibly convert an array: 1. Create a new php file and save a string in the $str variable; 2. Use the settype function to convert the string variable to an array type; 3. Use print_r Just output the array.
The operating environment of this article: windows7 system, PHP7.4 version, DELL G3 computer
php How to forcefully convert an array?
Create a new PHP file named test.php to explain how PHP forces the variable type to be converted to an array type.
In the test.php file, use the header() method to set the encoding format of the page to utf-8.
#In the test.php file, save a string in the $str variable.
In the test.php file, use the settype function to convert the string variable to an array type.
In the test.php file, use print_r to output the array.
Open the test.php file in the browser to view the results.
Recommended study: "PHP Video Tutorial"
The above is the detailed content of How to forcefully convert an array in php. For more information, please follow other related articles on the PHP Chinese website!