note 14812 added to function.split.php

From: Date: Wed, 15 Aug 2001 20:58:58 +0000
Subject: note 14812 added to function.split.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-16772@lists.php.net to get a copy of this message
[ Editor's Note: This is because split() accepts a regular expression. "." (period) represents to match anything, so you have to escape it if you want to actually split something with a period. alindeman@php.net ] Perhaps someone can tell me about this one I ran across. I was trying to split a filename by the periods that it contained so that I could get the extension and print a nifty image that corresponded. I used this code: $row = split('.',$filename); $extension = strtolower($row[sizeof($row)-1]); $docsize = getdocsize($dbh,$studentdocids[$i]); Well, $row ended up being empty until I changed the first line to be the following: $row = split('\.',$filename); I haven't seen this mentioned anywhere, so I figured that I would mention when in doubt, use the backslash. http://www.php.net/manual/en/function.split.php

« previous php.notes (#16772) next »