[UPHPU] Help me simplify this bit of code please?

Wade Preston Shearer lists at wadeshearer.com
Mon Aug 25 15:26:43 MDT 2008


On 25 Aug 2008, at 14:58, Ash wrote:

> Sorry, I forgot to add another line of the code that makes it so  
> that substr won't work, at least reading from right to left. From  
> left to right, it will, because there is always 2 chars for the  
> description, but perhaps only 1 for the year.

substr reads left to right. Craigs code will work if your description  
is always two characters and your year is one or more characters.

// Adds a slash before the first to characters of the string.
$series_description = '/'. substr($series, 0, 2);

// Gets the remaining characters after the first two characters.
$series_year = substr($series, 2);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2425 bytes
Desc: not available
Url : http://uphpu.org/pipermail/uphpu/attachments/20080825/3b38ce97/smime.bin


More information about the UPHPU mailing list