Answers for "save array to database 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
1

save array in mysql php

$names_arr = array(“Toni Abbah”,”Anastacia Mast”,”Soji Igbonna”);
// Associative Array
$users_arr[] = array(“username”=>”Torah”,”name”=>”Toni Abbah”);
$users_arr[] = array(“username”=>”Anamast”,”name”=>”Anastacia Mast”);
$users_arr[] = array(“username”=>”soggy”,”name”=>”Soji Igbonna”);
// Serialize the Array
$names_str = serialize($names_arr);
$users_str = serialize($users_arr);
Posted by: Guest on March-08-2021

Browse Popular Code Answers by Language