6

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.

Rohitink
  • 1,154
  • 3
  • 14
  • 21
  • 1
    whould this help? http://stackoverflow.com/questions/3634599/using-xml-node-names-with-hyphens-in-php – Geo Jan 30 '13 at 15:05

1 Answers1

15

Try using

$element->{'data-src'}
Mark Baker
  • 209,507
  • 32
  • 346
  • 385