[UPHPU] Help me simplify this bit of code please?
ashovi at qwest.net
Mon Aug 25 16:19:35 MDT 2008
Wade Preston Shearer wrote:
> 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);
Ah, right you are. It worked as expected.
Anyone else ever been to frazzled to actually read, or more importantly,
understand, what their code comments actually say? :)
More information about the UPHPU