This article will introduce to you the methods of saving text in php arrays and decoding text into arrays. Students who need to know more can refer to it.
Example
The code is as follows
代码如下 |
复制代码 |
function string2array($data) {
if($data == '') return array();
@eval("$array = $data;"); return $array;
}
|
|
Copy code
|
代码如下 |
复制代码 |
* @param array $data 数组
* @param bool $isformdata 如果为0,则不使用new_stripslashes处理,可选参数,默认为1
* string 返回字符串,如果,data为空,则返回空 */
function array2string($data, $isformdata = 1) {
if($data == '') return '';
if($isformdata) $data = new_stripslashes($data);
return addslashes(var_export($data, TRUE));
}
|
function string2array($data) {
if($data == '') return array();
@eval("$array = $data;"); return $array; |
}
/**Convert array to string
The code is as follows
|
Copy code
* @param array $data array
* @param bool $isformdata If it is 0, new_stripslashes processing is not used, optional parameter, default is 1
* string returns a string, if data is empty, returns empty*/
function array2string($data, $isformdata = 1) {
if($data == '') return '';
if($isformdata) $data = new_stripslashes($data);
return addslashes(var_export($data, TRUE));
}
http://www.bkjia.com/PHPjc/631259.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631259.htmlTechArticleThis article will introduce to you the methods of saving text in php arrays and decoding text into arrays. Students who need to know more Available for reference. Example code is as follows Copy code function string2ar...
|
|