In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article introduces the knowledge of "how php forcibly converts strings into arrays". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Php forcibly converts a string into an array: 1, add the target type "(array)" enclosed in parentheses before the string variable to be converted, syntax "(array) $str"; 2, use the settype () function to set the type of variable, syntax "settype ($str," array ")".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Method 1: add the target type enclosed in parentheses (array) before the string variable to be converted
Output result:
Method 2: use the settype () function
Settype ()-sets the type of variable
Syntax: settype ($var, $type)
The possible values for type are:
"boolean" (or "bool", starting with PHP 4.2.0)
"integer" (or "int", starting with PHP 4.2.0)
"float" (available only after PHP 4.2.0, "double" used in older versions is now disabled)
"string"
"array"
"object"
"null" (since PHP 4.2.0)
Example: convert the string $str to an array
Output result:
Note: settype () modifies the type of the variable itself, returns true if the setting is successful, and false if it fails.
So, in the above example, printing the variable $str using var_dump ($str) outputs an array structure.
That's all for "how php forcibly converts strings to arrays". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.