An Interest In:
Web News this Week
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
- March 26, 2024
March 25, 2022 05:14 am GMT
Original Link: https://dev.to/codeanddeploy/how-to-print-write-array-values-to-files-in-php-105
How To Print & Write Array Values to Files in PHP
Originally posted @ https://codeanddeploy.com visit and download the sample code: https://codeanddeploy.com/blog/php/how-to-print-write-array-values-to-files-in-php
In this post, I will share a short and simple code on how to print and write array values to files in PHP. If you have a task or problem that needs to write the array value to a file then this is for you. In this example, I'm using file_put_contents() to put the value to a file. And PHP_EOL to newline after loop the array values.
<?php$contents = '';$programmingLanguages = ['PHP', 'PYTHON', 'C#', 'C++'];foreach ($programmingLanguages as $programmingLanguage) { $contents .= $programmingLanguage.PHP_EOL;}file_put_contents('filename.txt', $contents, true);?>
Thanks for reading. I hope this tutorial can help you. Kindly visit here https://codeanddeploy.com/blog/php/how-to-print-write-array-values-to-files-in-php if you want to download this code.
Happy coding :)
Original Link: https://dev.to/codeanddeploy/how-to-print-write-array-values-to-files-in-php-105
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To