Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 23 Jan 2017, 15:11
Mickie D Mickie D is offline
 
Join Date: Jun 2002
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

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

using preg match I just want to grab the road names, without the London and the postcodes (N7 OBH)

So I would like the preg replace to cycle each line and remove everything that is not a road name.

LEAVING THIS:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


being completely honest I do not even know where to start with preg replace I am losing my mind here

Cheers All

Mick
__________________
Digitalworldz Satellite Cable TV Forums
Cable, Satellite, Consoles, Mobile Phones, Audio Visual, and general chat
Reply With Quote
  #2  
Old 23 Jan 2017, 15:22
Dave Dave is offline
 
Join Date: Jun 2010
Real name: Dave
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.
__________________
https://technidev.com - security, development, exploits, vBulletin
dave[at]technidev[dot]com

Contact me for custom vBulletin 3/4 work & server/website management.
Reply With Quote
  #3  
Old 23 Jan 2017, 15:57
Mickie D Mickie D is offline
 
Join Date: Jun 2002
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
__________________
Digitalworldz Satellite Cable TV Forums
Cable, Satellite, Consoles, Mobile Phones, Audio Visual, and general chat
Reply With Quote
  #4  
Old 23 Jan 2017, 16:03
Dave Dave is offline
 
Join Date: Jun 2010
Real name: Dave
Yes, using the strpos function you can check whether it contains the string London.

Something like:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
https://technidev.com - security, development, exploits, vBulletin
dave[at]technidev[dot]com

Contact me for custom vBulletin 3/4 work & server/website management.
Reply With Quote
  #5  
Old 23 Jan 2017, 16:12
Mickie D Mickie D is offline
 
Join Date: Jun 2002
Originally Posted by Dave View Post
Yes, using the strpos function you can check whether it contains the string London.

Something like:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.
Thanks Dave at the moment I have this code.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So I am thinking with your code it will be


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Digitalworldz Satellite Cable TV Forums
Cable, Satellite, Consoles, Mobile Phones, Audio Visual, and general chat
Reply With Quote
  #6  
Old 23 Jan 2017, 17:34
Dave Dave is offline
 
Join Date: Jun 2010
Real name: Dave
Something like this should work:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
https://technidev.com - security, development, exploits, vBulletin
dave[at]technidev[dot]com

Contact me for custom vBulletin 3/4 work & server/website management.
Reply With Quote
  #7  
Old 23 Jan 2017, 20:07
Mickie D Mickie D is offline
 
Join Date: Jun 2002
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
__________________
Digitalworldz Satellite Cable TV Forums
Cable, Satellite, Consoles, Mobile Phones, Audio Visual, and general chat
Reply With Quote
  #8  
Old 09 Feb 2017, 12:45
Mickie D Mickie D is offline
 
Join Date: Jun 2002
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

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

And in the template I am using the following to call the output


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Thanks Dave
__________________
Digitalworldz Satellite Cable TV Forums
Cable, Satellite, Consoles, Mobile Phones, Audio Visual, and general chat

Last edited by Mickie D; 09 Feb 2017 at 15:04.
Reply With Quote
  #9  
Old 09 Feb 2017, 22:05
Dave Dave is offline
 
Join Date: Jun 2010
Real name: Dave
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.
__________________
https://technidev.com - security, development, exploits, vBulletin
dave[at]technidev[dot]com

Contact me for custom vBulletin 3/4 work & server/website management.
Reply With Quote
  #10  
Old 10 Feb 2017, 16:14
Mickie D Mickie D is offline
 
Join Date: Jun 2002
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 10 Feb 2017 at 18:07 ---------------

Hi Dave,

I put road into a foreach array, but its still not giving me any luck.


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

let me know what you think, and thank you

Mick

--------------- Added 11 Feb 2017 at 14:55 ---------------

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


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Digitalworldz Satellite Cable TV Forums
Cable, Satellite, Consoles, Mobile Phones, Audio Visual, and general chat

Last edited by Mickie D; 11 Feb 2017 at 14:56.
Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML, TXT, JAVA Integrator 2.0 Automatically display any HTML, TXT or JAVA file in vB Erwin vBulletin 2.x Full Releases 102 11 Oct 2005 15:55



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 11:22.

Layout Options | Width: Wide Color: