将数组元素分配给 PHP 中的变量 [英] Assign array element to variable in PHP
本文介绍了将数组元素分配给 PHP 中的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这是一个愚蠢的问题,但我被困住了!我有以下数组:
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:wampwwwWeCodecode.php(29) : eval()'d code [line] => 3 )
我想要一个变量 $var
来包含 [message] 元素的字符串.我正在尝试通过索引访问数组,但它引发了偏移错误!那我能做什么?我认为这很简单,但我坚持这样做了.
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'];
在这种情况下,message
是您的数组索引.
In this case, message
is your array index.
这篇关于将数组元素分配给 PHP 中的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文