
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Cast Variable to Array in PHP
To cast variable to array, use the below syntax −
$yourNewVariableName=(array)$yourVariableName;
The PHP code is as follows −
Example
<!DOCTYPE html> <html> <body> <?php $nameArray=Array('Mike','Sam','David'); $valueArray=(array)$nameArray; print_r($valueArray); ?> </body> </html>
Output
Array ( [0] => Mike [1] => Sam [2] => David )
Advertisements