PHP键值对数组到字符串

Let's say I have an array that looks like this:

$args = array(
  'format' => 'file',
  'type' => 'page',
  'name' => 'Projects',
  'template' => 'default'
);

To get the values from the array keys I need to do this:

echo $args['format'];
echo $args['type'];
echo $args['name'];
echo $args['template'];

While it works, it feels more messy than needed. Is there a proper way to somehow convert it to this?

echo $format;
echo $type;
echo $name;
echo $template;

I'm aware of list but that only uses values and not keys.

查看全部
doulu3865
doulu3865
2017/03/30 08:19
  • string
  • php
  • arrays
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复