Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Simple HTML Dom Parser to Get hyphenated Attribute

Tags:

php

There is a similar question to this on StackOverflow. But, My question is a little different.

I have selected the image with the required class whose image I want. Earlier, I used

element->src

to get the value of src attribute, but now the site has replaced it with 'data-src'.

I do not have the full contents of a tag, hence I can not use preg_replace. I Have the reqired element, I just want to be able to do something like

$element->data-src

I am trying to do this using PHP SIMPLE HTML DOM PARSER, but no luck yet.

like image 818
Rohitink Avatar asked Jan 30 '13 14:01

Rohitink


1 Answers

Try using

$element->{'data-src'}
like image 172
Mark Baker Avatar answered Oct 31 '22 05:10

Mark Baker