The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Trying to import a txt file into VB
Hi guys,
I have a text file that I am trying to import into vbulletin to display I have managed to make the backend that actually puts the information into vbulletin (my template). But I am having problem with the PREG match and the output basically the txt files I am using have allot of crap in them and I am trying to weed out the good bits Example of text file Code:
Anson Road, London, N7 0AA Anson Road, London, N7 0AB Huddleston Road, London, N7 0AD Huddleston Road, London, N7 0AE London, N7 0AF (No Longer In Use) Huddleston Road, London, N7 0AG St Georges Avenue, London, N7 0AH St Georges Avenue, London, N7 0AJ Archibald Road, London, N7 0AL Archibald Road, London, N7 0AN Huddleston Road, London, N7 0AP London, N7 0AQ (No Longer In Use) Anson Road, London, N7 0AR Anson Road, London, N7 0AS Anson Road, London, N7 0AT Anson Road, London, N7 0AU London, N7 0AW (No Longer In Use) Anson Road, London, N7 0AX London, N7 0AY (No Longer In Use) London, N7 0AZ (No Longer In Use) London, N7 0BA (No Longer In Use) London, N7 0BB (No Longer In Use) Rowstock Gardens, London, N7 0BD Rowstock Gardens, London, N7 0BE Holbrooke Court, London, N7 0BF Rowstock Gardens, London, N7 0BG Rowstock Gardens, London, N7 0BH So I would like the preg replace to cycle each line and remove everything that is not a road name. LEAVING THIS: Code:
Anson Road Rowstock Gardens Holbrooke St Georges Avenue being completely honest I do not even know where to start with preg replace I am losing my mind here Cheers All Mick |
#2
|
|||
|
|||
What does the PHP code look like now?
You don't really need a preg_replace for this though, you can just iterate through each line, explode on comma's, then grab the first result. |
Благодарность от: | ||
Mickie D |
#3
|
|||
|
|||
Hi Dave thank you for that.
but then I would have loads of London, would it be possible to have a stop word like London IE if line starts with london - skip line??? I will post the code in the next hour once back in front of my main pc Dave... Thanks Dave |
#4
|
|||
|
|||
Yes, using the strpos function you can check whether it contains the string London.
Something like: PHP Code:
|
#5
|
|||
|
|||
Quote:
PHP Code:
PHP Code:
|
#6
|
|||
|
|||
Something like this should work:
PHP Code:
|
#8
|
|||
|
|||
Hi Dave,
Sorry for the delay, I had a family emergency. I am getting no output when using the code you posted Here is how I am using the code PHP Code:
PHP Code:
|
#9
|
|||
|
|||
In which hook did you add the code?
Also what you're doing now will keep overwriting the $sv variable, you'll want to add it to an array and then you can iterate through the array in the template. |
Благодарность от: | ||
Mickie D |
#10
|
|||
|
|||
Hi Dave,
No hook, it's an actual php page I made for vbulletin that has a template associated. I will create an array and post back, Thank you Dave. --------------- Added [DATE]1486753631[/DATE] at [TIME]1486753631[/TIME] --------------- Hi Dave, I put road into a foreach array, but its still not giving me any luck. PHP Code:
Mick --------------- Added [DATE]1486828541[/DATE] at [TIME]1486828541[/TIME] --------------- I managed to get it working, i went around the houses a little to get it into a comma seperated list - then used the unique array to clean duplicates. I AM SURE lol it could of been done much easier lol I always forget you need to .= to itterate the arrays but it works, if anyone wants it PHP Code:
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|