Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

php script for taking text

Question posted by: ajd335 (Member) on May 9th, 2008 05:56 PM
Hi ,
i have one file , which contains the result of one field from the database table.
look like this,
+---------------+
| email |
+---------------+
| |
| |
| |
| |
| abc@example.com |
| ddd@example.com
ppp@example.com |
+---------------+

i want to write a script which can give me results like,


abc@example.com
ddd@example.com
ppp@example.com..

I used sed command ,but not worked...
Markus's Avatar
Markus
Moderator
2,214 Posts
May 9th, 2008
06:57 PM
#2

Re: php script for taking text
No idea.

Show the code you're using now, and we can help from there.

Reply
ajd335's Avatar
ajd335
Member
104 Posts
May 9th, 2008
07:15 PM
#3

Re: php script for taking text
Hi..My file is like below :

+------------------+
| email |
+------------------+
| |
| |
| |
| |
| Join Bytes! |
| email |
| |
| |
| |
| |
| Join Bytes! |
| Join Bytes! |
| Join Bytes! |
| Join Bytes! |
| Join Bytes! |






is the table..that is in one text file..
I just want to have all the email address..

Expand|Select|Wrap|Line Numbers
  1. sed -n "/com/p"  result.txt > result.csv  

and it gives me

| abc @example.com|
| Join Bytes! |

something like this..
m missing something to avoid that extra |..
plz help..
Thanks

Reply
Markus's Avatar
Markus
Moderator
2,214 Posts
May 9th, 2008
07:59 PM
#4

Re: php script for taking text
No.
I mean the code you use to produce that file.
i.e. the php
<?php ... ?> that stuff

Reply
ajd335's Avatar
ajd335
Member
104 Posts
May 9th, 2008
08:12 PM
#5

Re: php script for taking text
Quote:
No.
I mean the code you use to produce that file.
i.e. the php
<?php ... ?> that stuff



Hi mark,
No, it's like i have one php file in which user enters certain things , Then using PHP script all data goes to the databse , From that table i need email field.

N that is the result.txt file in which i am storing the results from the Select query..

Hope i make things clear..

Reply
coolsti's Avatar
coolsti
Needs Regular Fix
295 Posts
May 9th, 2008
10:10 PM
#6

Re: php script for taking text
Perhaps you can explain to us why you seem to extract the data from the database to this text file, and then wish to parse the text file to get the email addresses?

PHP can certainly read your text file and extract the email addresses with the proper scripting, without needing to "leave PHP" to execute the shell command sed. However, it seems to me it would be more efficient and easier to program in the long run if you extracted the email addresses from the database directly with PHP, and not create this text file as middle man.

Reply
TheServant's Avatar
TheServant
Needs Regular Fix
462 Posts
May 11th, 2008
10:20 PM
#7

Re: php script for taking text
Quote:
Hi mark,
No, it's like i have one php file in which user enters certain things , Then using PHP script all data goes to the databse , From that table i need email field.

N that is the result.txt file in which i am storing the results from the Select query..

Hope i make things clear..



Hi ajd335,
The one php file you mentioned, we want that code. The output is of little use, and we do not taylor make code, rather fix code that has already been made and is not working as expected. Hope that helps.

Reply
Reply
Not the answer you were looking for? Post your question . . .
189,798 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
Top PHP Forum Contributors