在PHP中访问数组中的项

时间:2021-05-29 21:29:11

In PHP I would like to get the text value of the customer name tag. I write this code but this does not work. Would you please help me with this? Thank you

在PHP中,我想获取客户名称标签的文本值。我写这段代码,但这不起作用。你能帮我解决这个问题吗?谢谢

$customerName = $dom->get_elements_by_tagname("item");
$customernameValue = customerName[0]-> first_child()->node_value ();

2 个解决方案

#1


I'm not familiar with the library you're using, but it looks like you simply missed the $ before customerName on the second line.

我不熟悉你正在使用的库,但看起来你只是错过了第二行customerName之前的$。

#2


You're missing a $ sign, try this:

你错过了一个$符号,试试这个:

$customerName = $dom -> get_elements_by_tagname ("item");
$customernameValue = $customerName[0] -> first_child() -> node_value ();

#1


I'm not familiar with the library you're using, but it looks like you simply missed the $ before customerName on the second line.

我不熟悉你正在使用的库,但看起来你只是错过了第二行customerName之前的$。

#2


You're missing a $ sign, try this:

你错过了一个$符号,试试这个:

$customerName = $dom -> get_elements_by_tagname ("item");
$customernameValue = $customerName[0] -> first_child() -> node_value ();