Using Simple HTML Dom Parser to get a portable attribute

StackOverflow has a similar question. But, my question is a little different.

I selected an image with the required class whose image I want. I used to

element->src

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

I do not have the full content of the tag, so I cannot use preg_replace. I have a reqired element, I just want to do something like

$element->data-src

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

+5
source share
1 answer

Try using

$element->{'data-src'}
+11
source

All Articles