Home  >  Article  >  Backend Development  >  How to forcefully convert an array in php

How to forcefully convert an array in php

藏色散人
藏色散人Original
2021-11-30 09:58:542070browse

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.

How to forcefully convert an array in php

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.

How to forcefully convert an array in php

In the test.php file, use the header() method to set the encoding format of the page to utf-8.

How to forcefully convert an array in php

#In the test.php file, save a string in the $str variable.

How to forcefully convert an array in php

In the test.php file, use the settype function to convert the string variable to an array type.

How to forcefully convert an array in php

In the test.php file, use print_r to output the array.

How to forcefully convert an array in php

Open the test.php file in the browser to view the results.

How to forcefully convert an array in php

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn