Posted by gerry_w (gerry_w), 26 October 2005Can anyone please help a PHP beginner with a problem.
I'm pulling a load of data from a MySQL database, including a 13 character sort key. I want to produce a link to a URL which is based on the sort key
e.g. Sort_Key = 0006001000100
would refer to document '01000100.pdf' in folder 00/060
So I need to split Sort_Key into three separate strings thus
00 . 060 . 01000100
in order to build the URL.
Hope all that makes sense, and thanks in advance for any advice.
Posted by admin (Graham Ellis), 26 October 2005Hi, Gerry ... welcome.
I think unpack will do the trick ... here's an example ...
That's 2 characters into the element called Icecream, 2 characters into the element called Cream, and 4 into the element called custard.
The output is
Posted by gerry_w (gerry_w), 27 October 2005Thanks for that Graham. I ended up trawling the manual before I read your reply and I used the substr function instead, which seemed to do the job equally well.
From memory (the code's at work) my code was something like this (excuse any duff syntax)
Thanks again for taking the time to respond. I just had a quick trawl through the forum and there's loads here I can put to use
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: email@example.com • WEB: http://www.wellho.net • SKYPE: wellho