Hi Nick

On Mon, 13 Mar 2006 12:22:23 -0500, you wrote:

>Anthony,
>Quick question, sorry for bugging you, I wont anymore. 


That's alright - I'd sooner do this than the other stuff I have
today!  ;)

>In PHP how can I
>remove the text from an output on a command.

>I am running:
>$host_lookup = exec("/some/command/that/give/me output");
>
>The output is:
>
>mail:[EMAIL PROTECTED]
>
>I want on the next line to remove the "mail:" so the variable becomes
>only "[EMAIL PROTECTED]"
>
>You do this in your script with you do a host lookup, but I don't
>understand the syntax. If you can tell me how to do that, my script for
>emailing the end user on violation will be complete. I can share with
>you how I did it.

OK, you can do this two ways:

$email = preg_replace("/^.*:/","",$host_lookup);

or:

list ($null,$email) = explode (":",$host_lookup);


The $null variable will contain the word 'mail', $email will
contain your data.  I'd probably only use list/explode if there
were more than two elements though.

ant

--
Anthony W Owen BSc(Hons) <[EMAIL PROTECTED]>
ICT Network Manager.  Fallibroome High School.  Priory Lane
Macclesfield. Cheshire. SK10 4AF.  Tel: 01625 827 898
http://www.fallibroome.cheshire.sch.uk/

Reply via email to