- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Reading and storing a list as an array PHP
For this, you can simply use for loop.
Example
The PHP code is as follows
<!DOCTYPE html> <html> <body> <?php $list="10 20 30 40 50 60"; $arr=[]; $counter=0; for($i=0;$i<count($list);$i++){ if($list!==" "){ $arr[$counter++]=$list; } } foreach($arr as $t){ echo $t,"<br>"; } ?> </body> </html>
Output
This will produce the following output
10 20 30 40 50 60
Advertisements