Accessing an array element in PHP

In PHP, I would like to get the text value of the customer name tag. I am writing this code but it doesn't work. could you help me? thank you

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

      

0


a source to share


2 answers


I'm not familiar with the library you are using, but it looks like you just missed the $ before customerName

on the second line.



+10


a source


You are missing a sign $

, try this:



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

      

+3


a source







All Articles