0
0

More than 1 year has passed since last update.

【php】連想配列を見やすくする工夫

Posted at

なんてこともないことですが、
覚えてで忘れそうでもあるのでその備忘録がてら投稿します。

list()の活用

DBからレコードをSELCTするとカラム名に値が入っている形になっていると思う。 それをそのまま活用してもいいが、読みやすいかといわれると微妙。 そこでlist()を活用すると少しでも読みやすくなるかなと思った。 例えばこんな感じ。
$userData = ['田中太郎', '25', 'man', '東京都'];
list($name, $age, $gender, $address) = $userData;

ちょっとでも読みやすくなるコードを書いていきたいなという思いです。

0
0
0

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