Answers for "create array from text file php"

PHP
7

php save array to file

$arr1 = array ('a'=>1,'b'=>2,'c'=>3,'d'=>4,'e'=>5);
file_put_contents("array.json",json_encode($arr1));
# array.json => {"a":1,"b":2,"c":3,"d":4,"e":5}
$arr2 = json_decode(file_get_contents('array.json'), true);
$arr1 === $arr2 # => true
Posted by: Guest on March-09-2020
0

read file and convert each line in array php

$lines = file($filename, FILE_IGNORE_NEW_LINES);
Posted by: Guest on October-06-2020

Code answers related to "create array from text file php"

Browse Popular Code Answers by Language