php script for taking text – PHP

  php

Q(Question):

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…

A(Answer):

No idea.

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

A(Answer):

Hi..My file is like below :

+——————+
| email |
+——————+
| |
| |
| |
| |
| abc@example.com |
| email |
| |
| |
| |
| |
| abc@example.com |
| ajan@example.com |
| ha@example.com |
| abcd@example.com |
| web@example.com |

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


sed -n "/com/p" result.txt > result.csv

and it gives me

| abc @example.com|
| bbb@example.com |

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

A(Answer):

No.
I mean the code you use to produce that file.
i.e. the php
<?php … ?> that stuff

A(Answer):

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..

A(Answer):

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.

A(Answer):

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.

LEAVE A COMMENT