Skip to content

Instantly share code, notes, and snippets.

@Restoration
Created October 26, 2016 09:45
Show Gist options
  • Select an option

  • Save Restoration/2c9c9760a311ea9c77256342c28a6444 to your computer and use it in GitHub Desktop.

Select an option

Save Restoration/2c9c9760a311ea9c77256342c28a6444 to your computer and use it in GitHub Desktop.
CakePHP カタカナチェック
<?php
/**
* 全角カタカナ以外が含まれていればエラーとするバリデーションチェック
*
*
* @param array &$model
* @param array $wordvalue
* @return boolean
*/
function katakana_only( $wordvalue){
$value = array_shift($wordvalue);
return preg_match("/^[ァ-ヶー゛゜]*$/u", $value); // カタカナ
//return preg_match("/^[ァ-ヶー゛゜]*$/u", $value); // スペースも含むカタカナ
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment