Re: the last word of a string??

From: Date: Sun, 12 Aug 2001 14:17:22 +0000
Subject: Re: the last word of a string??
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-62306@lists.php.net to get a copy of this message
* zerosumzero@yahoo.com <zerosumzero@yahoo.com> [010812 08:08]: > on 8/12/01 2:21 AM, Mukul Sabharwal at mukulsabharwal@yahoo.com wrote: > > $arr = explode($lastline, " "); > > > > that puts lastline into arr which is an array and you > > can use the sizeof operator to get the nth (or the > > last) element. > > > > print $arr[sizeof($arr)]; > > > hmmm I tried this... it seems not to recognise the space. The sizeof($arr) > is always 1. The order of arguments above is wrong. It should be: $arr = explode(" ",$lastline); The separator must come before the string. See function.explode.html in the docs. -- Jan Wilson, SysAdmin _/*]; corocom@btl.net Corozal Junior College | |:' corozal.com corozal.bz Corozal Town, Belize | /' chetumal.com & linux.bz Reg. Linux user #151611 |_/ Network, SQL, Perl, HTML

« previous php.general (#62306) next »