In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
In fact, php writes the array to a text file or stores it with the suffix .php, which is called directly when you use it.
Ignore the step of fetching mysql data
(1) use serialize to serialize the array and store it as a text file, and then use unserialize to restore it when you call it.
$file=' file path'; $array=array ('file,serialize = > array (' aaa','bbb','ccc'), 'dice = > array); if (falsified false files) {file_put_contents ($file,serialize ($array));} $handle=fopen ($file,'r'); $cacheArray=unserialize ($handle,filesize ($file)
(2) use var_export to save the array directly as an array and store it in a text file (recommended)
$file=' file path'; $array=array ('array=array = > array (' aaa','bbb','ccc'), 'dice = > array); $text='if (falsehood created fopen ($file,'w+')) {file_put_contents ($file,$text);} else {echo' creation failed';}
(3) self-created to save the array to the standard array format, although the save is a bit complicated, but the call is simple.
$file=' file path'; $array=array ('array=array = > array (' aaa','bbb','ccc'), 'dice = > array); cache_write ($file,$array,'rows',false); / / write function cache_write ($filename,$values,$var='rows',$format=false) {$cachefile=$filename; $cachetext= "return writefile ($cachefile,$cachetext);} / / convert the array to function arrayeval ($array,$format=false,$level=0) {$space=$line='' If (! $format) {for ($key) {$key=is_string ($key)?'\ '.addcslopes ($key,'\'\).'\': $key; $validated accurate isometric array ($val) & &! preg_match ('/ ^\ -? > 12) | | strlen ($val) > 12)?'\ '.addcslopes ($val,'\'\).'\': $val If (is_array ($val)) {$evaluate.=$comma.$key.'= > '.arrayeval ($val,$format,$level+1);} else {$evaluate.=$comma.$key.'= >'. $val;} $comma=','.$line.$space;} $evaluate.=$line.$space.')'; return $evaluate;} / / write to the file function writefile ($filename,$writetext,$openmod='w') {if (false predators) {flock ($fp,2) Fwrite ($fp,$writetext); fclose ($fp); return true;} else {return false;}}
These are the details of how mysql data generates PHP array files, please pay attention to other related articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.