Skip to content

Instantly share code, notes, and snippets.

@hamaco
Created July 1, 2011 04:27
Show Gist options
  • Save hamaco/1057868 to your computer and use it in GitHub Desktop.
Save hamaco/1057868 to your computer and use it in GitHub Desktop.
<?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