字符串处理函数
时间:2006-05-30 来源:jingzhi
// {{{ insert_str(), delete_str(), index_str()
/**
* Basic string operate
*
* @param string $str need get sub string variable
* @param int $start start get sub string
* @param int $length need get string length
* @return string return sub string
* @version v0.1
* @create 2005-5-24
* @modified 2005-5-24
* @author heiyeluren
*/
function str_insert($str, $i, $substr)
{
for($j=0; $j
*/
function strcpy($s1, $s2)
{
if (strlen($s1) == NULL)
return;
if (!isset($s2))
return;
for ($i=0; $i
*/
function strcat($s1, $s2)
{
if (!isset($s1))
return;
if (!isset($s2))
return;
$newstr = $s1 . $s2;
return $newsstr;
}
// }}}
// {{{ php_encode(), php_decode()
/**
* Simple string encode/decode function
*
* @param string $str need code/encode string variable
* @return string code/encode after string
* @version v0.2
* @create 2005-3-11
* @modified 2005-5-24
* @author heiyeluren
*/
/* String encode function */
function php_encode($str)
{
if ($str=='' && strlen($str)>128)
return false;
for($i=0; $i31 && $c106 && $c128)
return false;
for($i=0; $i106 && $c31 && $c
*/
/* define crypt key */
$encrypt_key = 'abcdefghijklmnopqrstuvwxyz1234567890';
$decrypt_key = 'ngzqtcobmuhelkpdawxfyivrsj2468021359';
/* String encrypt function */
function php_encrypt($str)
{
global $encrypt_key, $decrypt_key;
if (strlen($str) == 0)
return false;
for ($i=0; $i
相关阅读 更多 +