Re: a function question

From: Date: Thu, 30 Dec 2004 10:04:30 +0000
Subject: Re: a function question
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-25206@lists.php.net to get a copy of this message
The function strpos might be better, preg_match is a bit of overkill if (strpos($mail,'@') == false) // error message else // okay message graeme. Dean Hayes wrote:
Try this i got this working without any problems prints everything out nice an neetly <?php $mail = "FOJOMO@yahoo.com";
    $user = "patrick";
    /*
    comment function to get on screen
    function usermail($user,$mail)
    {
    */
    global $user;
        global $mail;
        $user = ucwords($user); // capitalizes the 'p' in patrick
        $mail = strtolower($mail); // converts all of FOJOMO into lower case
if (preg_match("/@/" , $mail)) { // searches for the '@' sign // Used preg_match not strstr /* Place array details here that will work i do not know of arrays yet so i can not help here */ echo "Valid email address and username details here<p>\n" . $user . "\n<p>\n" . $mail . "<p>\n";
            } else {
    print "Please enter a valid e-mail address";   //default if test fails to //find the '@' sign
    }
// Function close //} ?> Dean "The Insane Guy" Hayes <-- I design and i redesign but still i never designed true beauty like you --> ~~~ Call me Insane call me Crazy but there is one thing i know i am That is someone that shall reach peoples hearts with words ~~~ ~~ PHP seems easy enough but what about this ASP now that looks hard ~~ From: Patrick Roane <fojomo@sbcglobal.net> To: php-windows@lists.php.net Subject: [PHP-WIN] a function question Date: Wed, 29 Dec 2004 21:06:43 -0800 (PST) I am trying to create a function that works with two arguments. the 1st needs to be a suername. The 2nd needs to be an email address. Next, I have to use case conversion functions to capitalize the first letter of the username and convert the email add. to lowercase characters and finaly check that it contains the @ sign. If I can't find the @ character, return false: otherwise, I return an array containing the converted arguments. Here is my code (which I can't get to work): <?php
        $mail = "FOJOMO@yahoo.com";
    $user = "patrick";
    function usermail( $user, $mail ) {
    global $user;
        global $mail;
        $user; = ucwords( $user ); // capitalizes the
    //'p' in patrick
        $mail; = strtolower( $mail ); // converts all
//of FOJOMO into lower case if ( strstr( $mail ), "@" )) {
    // searches for the '@' sign
user_array = explode("-", $user, $mail); // this //function (explode) creates the array
            } else {
    print "Please enter a valid e-mail address";   //
default if test fails to //find the '@' sign
    }
?> ===== ---------------- "forget your lust for the rich man's gold. All that you need, is in your soul. You can do this if you try. All that I want for you my son, is to be satisfied" ~ Lynard Skynard -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.windows (#25206) next »