Welcome Guest, Not a member yet? Register   Sign In
[solved] Helper Page Calling Other Helpers
#1

[eluser]Unknown[/eluser]
I have been using CI since Sunday, but I have read a lot up on it.

Yet for the life of me I cannot figure this out.

I have a helper page for functions I use a lot.

One of them is called sanitize, the idea is you send an array for DB results and it converts the date to human readable, converts one of my fields into a url by adding dashes etc.

In that function I want to call another function located in the same helper page....but it will not let me.

Code:
// Sanitizes result array to make it human readable and returns it
if(!function_exists('sanitize')) {
    function sanitize($result) {
        foreach($result as $row) {
            // Convert game name to a url with dashes in lowercase
            $row['game_name'] = url_title($row['game_name'], 'dash', TRUE);
            
            // Convert release date to Mm DD, YY (ex. Jan 2, 11)
            list($year, $month, $day) = explode('-', $row['release_date']);
            
            if($year === 9999) {
                $row['release_date'] = 'TBD';
            } else {
                $row['release_date'] = date('M j, Y', mktime(0, 0, 0, $month, $day, $year));
            }

            // Convert genre from DB to human readable and then to a url with dashes in lowercase
            $row['genre'] = url_title(getGenre($row['genre']), 'dash', TRUE);
        }

        return $result;
    } // end sanitize
}

See the url_title(getGenre{$row['genre']), 'dash', TRUE)?

I am trying to use the result from the function getGenre and then create a url out of it.

I know its not the double function call. The date manipulation I am doing was also a function that I moved as well.




Theme © iAndrew 2016 - Forum software by © MyBB