Welcome Guest, Not a member yet? Register   Sign In
A more-useful uri_to_assoc
#9

[eluser]CtheB[/eluser]
uri_to_assoc(4) returns:

segment4 => segment5
segment6 => segment7
segment8 => segment9

however, if our key/value changes from segment4/segment5 to segment5/segment6, we can not control this dynamically with uri_to_assoc.

With xwero's modification to segment() we can control this, because it doesn't mather if the key is in segment4 or segment5, we still get the correct value.

(just like in $_GET)... with xwero's modification, the segment() method acts the same as $_GET, if the parameter is a string.
The only difference is now you have key1/value1/key2/value2 instead of ?key1=value1&key2=value2.
$this->uri->segment('archive') returns the same result as $_GET['archive'] no mather wich segment the archive is.

Example:

my-site.com/news/archive/5
my-site.com/news/this-is-the-first-item/archive/5

is the same as:

my-site.com/news?archive=5
my-site.com/news/this-is-the-first-item?archive=5

with xwero's modification, we could get the 5 without telling the method at wich segment the key/value pair starts,
wich is the same as $_GET acts...


Messages In This Thread
A more-useful uri_to_assoc - by El Forum - 04-24-2009, 03:34 PM
A more-useful uri_to_assoc - by El Forum - 04-24-2009, 05:18 PM
A more-useful uri_to_assoc - by El Forum - 04-24-2009, 08:59 PM
A more-useful uri_to_assoc - by El Forum - 04-24-2009, 09:28 PM
A more-useful uri_to_assoc - by El Forum - 05-17-2009, 12:19 PM
A more-useful uri_to_assoc - by El Forum - 05-17-2009, 02:56 PM
A more-useful uri_to_assoc - by El Forum - 05-17-2009, 03:09 PM
A more-useful uri_to_assoc - by El Forum - 05-17-2009, 04:18 PM
A more-useful uri_to_assoc - by El Forum - 05-17-2009, 04:46 PM
A more-useful uri_to_assoc - by El Forum - 05-17-2009, 06:37 PM
A more-useful uri_to_assoc - by El Forum - 05-21-2009, 01:14 PM
A more-useful uri_to_assoc - by El Forum - 06-04-2009, 02:52 PM
A more-useful uri_to_assoc - by El Forum - 06-04-2009, 03:23 PM
A more-useful uri_to_assoc - by El Forum - 06-04-2009, 03:38 PM
A more-useful uri_to_assoc - by El Forum - 06-04-2009, 04:21 PM
A more-useful uri_to_assoc - by El Forum - 06-04-2009, 04:31 PM
A more-useful uri_to_assoc - by El Forum - 06-04-2009, 04:46 PM
A more-useful uri_to_assoc - by El Forum - 06-05-2009, 12:50 AM
A more-useful uri_to_assoc - by El Forum - 07-10-2009, 10:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB