开发者

Removing an element from the array knowing its name

I have this array in PHP

array(5) {
  ["mai_id"] => string(1) "3开发者_如何学运维"
  ["mai_logo"] => string(0) ""
  ["mai_title"] => string(16) "Vitrine Cultural"
  ["mai_description"] => NULL
  ["mai_description2"] => NULL
}

And I'd like to remove ["mai_description"] and get only

array(5) {
  ["mai_id"] => string(1) "3"
  ["mai_logo"] => string(0) ""
  ["mai_title"] => string(16) "Vitrine Cultural"
  ["mai_description2"] => NULL
}

is there any way?


Yup, use unset()

unset( $array['mai_description'] );


unset($array['mai_description'])

but use documentation, please.


unset($array["mai_description"]);

ought to do the trick.

/ edited to fix syntax error even though it's the same as Peter's

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜