Jump to content
Sign in to follow this  
JERO79

How To Output A Nodevalue To A $String?

Recommended Posts

I am using the code below to extract some information from a website: $doc = new DOMDocument();$doc->loadHTML($html);$xpath = new DomXpath($doc); foreach($xpath->query('//img/@alt') as $node){ echo $node->nodeValue."|";} An example of the output is: 1|3|.5|statusB|8|5|.0| I want to use the code below to split this output in parts: $splitdata = explode('|', $input);echo "$splitdata[0], $splitdata[1], $splitdata[2], $splitdata[3], $splitdata[4], $splitdata[5], $splitdata[6]"; But how can I get the output from echo $node->nodeValue."|"; into the string $input?

Share this post


Link to post
Share on other sites
[i]foreach($xpath->query('//img/@alt') as $node){[/i][i] $input[]=$node->nodeValue;[/i][i]}[/i]

you can directly store it in array something like above.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...