LoginSignup
0
0

More than 5 years have passed since last update.

多次元配列のフィルタリング

Posted at

現在、自己学習記録のプログラムを作成中で、わからないことがあります。
教えていただければ幸いです。
下記の画面で入力した値を入力確認画面にてGETで受け取ります。
その際に、各入力値が多次元配列の場合のフィルタリングをしたいのですが、filter_input関数だとうまくいきません。
image.png

↓↓↓↓↓下記がコードになります。※とりあえず$yearのみフィルタリングを行おうとしています。

if (isset($_GET) && $_GET != '') {
//日付を取得
if ($_GET['date']['year'] != '' && $_GET['date']['month'] != '' && $_GET['date']['day'] != '' ){

    $year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_SPECIAL_CHARS);

    $month = $_GET['date']['month'];
    $day   = $_GET['date']['day'];
    $date =  "20{$year}年{$month}月{$day}日";
}

入力の仕方がおかしいのは認識しています。
この関数以外を本来は使うべきなのでしょうか。初歩的な質問ですが、よろしくお願いします。

0
0
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0