How to Use array_walk in Codeigniter

The key thing to know is that you need give array_walk / array_walk_recursive an array function lets_walk() { $sweet = array(‘a’ => ‘apple’, ‘b’ => ‘banana’); $fruits = array(‘sweet’ => $sweet, ‘sour’ => ‘lemon’); array_walk_recursive($fruits, array($this, "walk_print")); } function walk_print($value, $key){ print($value); }

May 2, 2010 • Tags: , • Posted in: Tutorial • No Comments

Special Characters in Codeigniter Urls

When Codeigniter gets variables from the URL, it returns the variables in HTML friendly characters. I couldn’t figure out why my left and right brackets were acting up. So what you need to do is just use a simple php string replace function and replace the special characters you need. $string = str_replace("(", "(", $string) [...]

April 16, 2010 • Tags: , • Posted in: True • No Comments

PHP simple array to object array

I’m probably a retard, but I couldn’t find a function that would change a simple array into object form. Well for anyone who finds this, here is a simple function to convert a one dimensional php array. function convert($array_in, $name=”) { $array_out = array(); foreach($array_in as $item) { array_push($array_out, array($name => $item)); } return $array_out; }

April 16, 2010 • Tags:  • Posted in: True • No Comments