Welcome Guest, Not a member yet? Register   Sign In
Array function
#1

[eluser]frist44[/eluser]
I know this is a stupid question, but is there a way to perform a function like "urlencode" to every value in an associative array easily?

Right now, I'm doing the code below, and it works, I just figured there's a more elegant way to do this.

Code:
foreach ($arr_uri as $key => $value) {
            $fixed[$key] = urlencode($value);
        }
#2

[eluser]jáquer[/eluser]
array_map()

Code:
$arr_uri = array_map('urlencode', $arr_uri);
#3

[eluser]frist44[/eluser]
Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB