RE: [PHP] Returning info from a function

From: Date: Tue, 21 Aug 2001 23:16:00 +0000
Subject: RE: [PHP] Returning info from a function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-63792@lists.php.net to get a copy of this message
I'll assume the & is legit (never used it in PHP personally) here is a restructured function assuming all your provided code does what you want !untested! function &getpath($search) { # removed $path and $search... $search is already passed # and you are only using $path in the function $a = `/bin/ls -al /home/sites/ | awk {'print $9" "$10" "$11" "'} | grep $search`; $items = explode ("www.", $a); For($i = 0; $i< (count($items)/1); $i +=1){ $path[]=strstr(($items[$i]), '/'); #you are doing this # multiple times, and unless you want to keep # overwriting the $path variable you need to # create an array } return $path; # last thing to do is return your values } $path=&getpath($search); >-----Original Message----- >From: Richard Kurth [mailto:rkurth@pacifier.com] >Sent: Tuesday, August 21, 2001 5:46 PM >To: php >Subject: [PHP] Returning info from a function > > >Could somebody tell me way this function will not work I know the >script inside the function works because I have tested it but when I >put it in a function all I get back when I call it is a 1 > > >function &getpath($search) { >Global $search,$path; >$a = `/bin/ls -al /home/sites/ | awk {'print $9" "$10" "$11" >"'} | >grep $search`; >$items = explode ("www.", $a); > For($i = 0; $i< (count($items)/1); $i +=1){ > $path=strstr(($items[$i]), '/'); > return $path; >} >} > > $path=&getpath($search); > > > > > > > > > > > > > >Best regards, > Richard >mailto:rkurth@pacifier.com > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net > > >

« previous php.general (#63792) next »