RE: [PHP] substr?

From: Date: Tue, 18 Jun 2002 16:12:45 +0000
Subject: RE: [PHP] substr?
Groups: php.general 
Request: Send a blank email to php-general+get-102814@lists.php.net to get a copy of this message
> -----Original Message----- > From: Chris Knipe [mailto:savage@savage.za.org] > Sent: 17 June 2002 09:28 > > Is this right? It seems to me that substr is working in reverse? > > $string = "1234567890"; // Always numerical, always 10 chars. > if (!substr($string, 0, -7) == "083") { > echo "not 083\n"; > } else { > // Exists here. > echo "is 083\n"; > } > > Due to the reverse if, shouldn't it exit not 083? But you haven't inverted the if, just the substr; the above is the same as: if ( (!substr($string, 0, -7)) == "083") { which doesn't actually make a lot of sense! Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.general (#102814) next »