Re: a function question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Here is my code (which I can't get to work):

<?php

/** Note that my code / comments are untested, but should be helpful. */



$mail = "FOJOMO@xxxxxxxxx";
$user = "patrick"; function usermail( $user, $mail ) {

/** We don't need global $user or $mail since these are passed into the function. In fact doing this just might confuse yourself... */


$user; = ucwords( $user ); // capitalizes the //'p' in patrick

/** The above is incorrect. A semicolon terminates a line! Try the following: */


$user = ucwords( strtolower( $user ) );

        $mail; = strtolower( $mail ); // converts all
//of FOJOMO into lower case
		

$mail = strtolower( $mail );



if ( strstr( $mail ), "@" )) {

/** Agreed with Graeme's previous comment, strpos is fine for this. */

if ( strpos( $mail, '@' ) ) {


    // searches for the '@' sign
  user_array = explode("-", $user, $mail); // this

$user_array = explode( '-', $user);

//function (explode) creates the array

/** Check the manual page for explode http://php.net/manual/en/function.explode.php


Why do you explode on hyphens? Do you have a system to prevent users from creating email addresses without hyphens? And what do you want to do with this array? */

} else {
print "Please enter a valid e-mail address"; //
default if test fails to //find the '@' sign

}



/** Nothing is returned either... did you want something? */ return $user_array;

} /** end of function usermail */


/** Now we test the function and echo the result of running the function. */ $result = usermail( $user, $mail ); print nl2br( print_r( $result ) );


	
		
?>




-- Teach a person to fish...

Ask smart questions: http://www.catb.org/~esr/faqs/smart-questions.html
PHP Manual: http://php.net/manual/
php-general archives: http://marc.theaimsgroup.com/?l=php-general&w=2

--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux