Return array from function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dgkindy
Forum Newbie
Posts: 15
Joined: Tue Sep 22, 2009 8:53 pm

Return array from function

Post by dgkindy »

I am trying to return a couple variables from a function. I am getting the following error.

Error Message

Parse error: parse error in D:\Documents and Settings\414004425\My Documents\My Websites\PETdb\md4c5.php on line 177

Code: Select all

Function purchase_request($string) {
        return array($pr1, $pr2) = explode("/",$string);   
    }
I have been looking at the book and cannot see the problem. What am I misssing?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Return array from function

Post by requinix »

Code: Select all

return explode("/", $string);
explode() returns an array already. Don't mess with it.
dgkindy
Forum Newbie
Posts: 15
Joined: Tue Sep 22, 2009 8:53 pm

Re: Return array from function

Post by dgkindy »

That did it thanks for the help
Post Reply