1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
4 * Encodes CI segments for using them in URLs.
5 * Useful when the last page needs to be remembered in the URL.
6 * The function replaces all '/' with '\' and then encodes with urlencode PHP
9 * @param string $str segments string to encode
10 * @param string $disallowed_prefix if $str start with $disallowed_prefix the
11 * function returns a null string.
12 * @return string the encoded segments
14 function urlencode_segments($str, $disallowed_prefix = NULL)
16 if ($disallowed_prefix && strpos($str, $disallowed_prefix) === 0)
19 $str = str_replace('/', '\\', $str);
20 return urlencode($str);
24 * Decodes a string encoded with urlencode_segments helper.
26 * @param string $str string to decode
27 * @return string the valid CI segments decoded from $str
29 function urldecode_segments($str)
31 $str = urldecode($str);
32 return str_replace('\\', '/', $str);
35 /* End of file MY_url_helper.php */
36 /* Location: ./application/helpers/MY_url_helper.php */