Good day,

You're returning $current_page_name.

$current_page_name is set to the return value for array_slice.

And array_slice returns an array.

So, $current_page_name will be an array.

So, you'll always return an array.

I think what you're trying to do is return one particular element out of the
array.  If that's the case, just use something like:

return $current_page_name[-1]

to return the last element in the array.

Darren Gamble
Planner, Regional Services
Shaw Cablesystems GP
630 - 3rd Avenue SW
Calgary, Alberta, Canada
T2P 4L4
(403) 781-4948

-----Original Message-----
From: Erik Price [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 13, 2002 2:56 PM
Subject: [PHP] how a function 'return' statement works

Can anyone give my puny mind an explanation as to why the following 
function only returns the value "Array" ?

# ===============================================================
# get_current_page_name()
# ---------------------------------------------------------------
# Returns the current document
#  Arguments
# -----------
# no arguments
# ===============================================================

function get_current_page_name()
    $current_page_name = explode("/", $_SERVER['PHP_SELF']);
    $current_page_name = array_slice($current_page_name, -1);
    return $current_page_name;

(I know this does the same thing as 'basename("$_SERVER['PHP_SELF'])', I 
just want to understand something a bit more fundamental to the way 
functions work)




Erik Price
Web Developer Temp
Media Lab, H.H. Brown

PHP General Mailing List (
To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to