($str, $i, $n); $str = str_insert($str, $i, $newstr); } return $str; } // }}}
/************ 以下串处理函数是PHP中没有的,自己写着玩 ***************/
// {{{ 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 <hyeiyeluren@163.com> */ function str_insert($str, $i, $substr) {
for($j=0; $j<$i; $j++) { $startstr .= $str[$j]; }
for ($j=$i; $j<strlen($str); $j++) { $laststr .= $str[$j]; } $str = ($startstr . $substr . $laststr); return $str; }
function str_delete($str, $i, $j) { for ($c=0; $c<$i; $c++) { $startstr .= $str[$c]; }
for ($c=($i+$j); $c<strlen($str); $c++) { $laststr .= $str[$c]; }
$str = ($startstr . $laststr);
return $str; } // }}}
// {{{ strcpy() /** * Use designate sub string replace string * * @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-27 * @modified 2005-5-27 * @author heiyeluren <hyeiyeluren@163.com> */ function strcpy($s1, $s2) { if (strlen($s1) == NULL) return; if (!isset($s2)) return;
for ($i=0; $i<strlen($s1); $i++) { $s2[] = $s1[$i]; } return $s2; } // }}}
// {{{ strcat() /** * Use designate sub string replace string * * @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-27 * @modified 2005-5-27 * @author heiyeluren <hyeiyeluren@163.com> */ 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 <hyeiyeluren@163.com> */
/* String encode function */ function php_encode($str) { if ($str=='''' && strlen($str)>128) return false;
for($i=0; $i<strlen($str); $i++) { $c = ord($str[$i]); if ($c>31 && $c<107) $c += 20; if ($c>106 && $c< |