指定数组元素在PHP变量 [英] Assign array element to variable in PHP

查看:115
本文介绍了指定数组元素在PHP变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这是一个愚蠢的问题,但我stucked!
我有以下数组:

I know this is a silly question, but i'm stucked! I have the following array:

Array ( [type] => 8 [message] => Use of undefined constant hola - assumed 'hola' 
 [file] => C:\wamp\www\WeCode\code.php(29) : eval()'d code [line] => 3 ) 

我想要一个变量 $ VAR 有[消息]元素的字符串。我试图通过索引访问数组,但它引发了我的偏移误差!所以,我能做些什么?我认为这是pretty简单,但我坚持这一点。

I want a variable $var to have the string of [message] element. I'm trying to access the array via indexes, but it throws me offset errors! So what can I do? I think is pretty simple, but I'm stuck with that.

推荐答案

您可以使用:

$var = $array['message'];

在这种情况下,的消息是数组索引。

In this case, message is your array index.

这篇关于指定数组元素在PHP变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆