![]() |
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 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 being completely honest I do not even know where to start with preg replace I am losing my mind here Cheers All Mick |
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. |
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 |
Yes, using the strpos function you can check whether it contains the string London.
Something like: PHP Code:
|
Quote:
PHP Code:
PHP Code:
|
Something like this should work:
PHP Code:
|
Thanks Dave for all your help mate.
I will get this code tested tomorrow when I am back on my work PC. Will report back then, thank you very much. Mick |
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:
|
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. |
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:
|
All times are GMT. The time now is 03:51 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|