0
$doc = new DOMDocument();
$document=$doc->loadHTML($introtext);
$imageparse = $doc->getElementsByTagName('img');
$i=0;

foreach ($imageparse as $parser) {

$images[$i]= $parser->getAttribute('src');
$i++;
}
var_dump($images[0]);

INTROTEXT VAR:

<p>ssdasadssdasadssd</p>
<p>ssdasad</p>
<p>ssdasad</p>
<p>ssdasad</p>
<p><img src="images/images.jpg" alt="" /></p>
<p>ssdasad</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

var_dump($images[]) returns always the first character of the string,instead of whole string. example: "images/images.jpg" = i . if i set src="gotrekt" , i get "g" as output. The funny thing is that yesterday in my home i used the same code to do it and it worked,i just copy pasted my files with usb today in work.

ALso i notice that var_dump($introtext) give this :

enter image description here

this isnt legit right ? SHouldnt it shows the html tags instead of getting executed? $introtext is the content of Joomla Articles so maybe its not a coding but a joomla issue at the end ? I removed all the security patterns for articles but still nothing changed.

Barmar
  • 741,623
  • 53
  • 500
  • 612
IseNgaRt
  • 601
  • 1
  • 4
  • 22
  • `var_dump()` just prints the value of the variable. If it contains HTML codes, and you send that to a browser, the browser will render it. You can use `echo htmlentities(print_r($variable, true));` to encode it so you can see the actual HTML. – Barmar Nov 27 '14 at 09:50
  • 1
    Are you sure you're assigning `$images[$i]` and not just to `$images`? If you do the latter, `$images` will be a single string, not an array, and `$images[0]` will get the first character of the string. – Barmar Nov 27 '14 at 09:52
  • @Barmar thanks for that didnt know it :) I found out the error ! You gave me an idea BArmar and i var_dump($images) and returned me another array, in the head of my file there was an included file that had inside it a var named $images , it was a variable collision! – IseNgaRt Nov 27 '14 at 10:01

0 Answers0