Home  >  Article  >  Backend Development  >  Saving text in php array and decoding text into array_PHP tutorial

Saving text in php array and decoding text into array_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:00:19846browse

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;

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...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn