1

How do i get the image url inside data-src?

<img src="http://example.com/lightbox-blank.gif" data-src="http://example.com/img/2f8556.1.jpg" id="pic1545" /></a>

i try this and get error "Use of undefined constant src - assumed 'src'" with no result

$html->find('div.thumb img',$i)->data-src;

Help please thank you

1 Answer 1

3

What you tried is almost right, except for the part which you are using data-src as an attribute name. For such attribute names (i.e. including special chars) you can use ->{'attribute-name'} syntax:

$html = str_get_html('<img src="http://example.com/lightbox-blank.gif" data-src="http://example.com/img/2f8556.1.jpg" id="pic1545" />');

print $html->find("img", 0)->{'data-src'};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.