Created
July 1, 2011 04:27
-
-
Save hamaco/1057868 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function pickupFromTextArea($needle, $subject) { | |
$pattern = "/{$needle}(.*)/"; | |
if (preg_match($pattern, $subject, $matches) === 1) { | |
return trim($matches[1], "\r"); | |
} | |
return false; | |
} | |
$textarea = "発着地を入力下さい。 | |
出発地:上野 | |
到着地:大井町 | |
"; | |
var_dump(pickupFromTextArea("出発地:", $textarea)); | |
var_dump(pickupFromTextArea("到着地:", $textarea)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment