gdfghd - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of gdfghd.php
- <?php
- $email = "john_smith@hotmail.com"; // Or Use $_GET['subject']; / $_POST['subject']; depending on form
- $parts = explode("@",$email); // Splits the email at the @ symbol
- $username = $parts[0]; // Can be used as a username if you'd like, but we'll use it to find names anyway
- $delimiters = array(".", "-", "_"); // List of common email name delimiters, feel free to add to it
- foreach ($delimiters as $delimiter){ // Checks all the delimiters
- if ( strpos($username, $delimiter) ){ // If the delimiter is found in the string
- $parts_name = preg_replace("/\d+$/","", $username); // Remove numbers from string
- $parts_name = explode( $delimiter, $parts_name); // Split the username at the delimiter
- break; // If we've found a delimiter we can move on
- }
- }
- if ( $parts_name ){ // If we've found a delimiter we can use it
- $fname = ucfirst( strtolower( $parts_name[0] ) ); // Lets tidy up the names so the first letter is a capital and rest lower case
- $lname = ucfirst( strtolower( $parts_name[1] ) );
- /* This code just shows what you can do with the names, but you can use it for something more interesting! */
- echo $fname . ' ' . $lname;
- }