UPDATED:
for multiple occurrences you can try this:
In PHP:
<?php
$url = 'testing.php';
$content = file_get_contents($url);
function getContents($str, $start, $end) {
$contents = array();
$startDelimiterLength = strlen($start);
$endDelimiterLength = strlen($end);
$startFrom = $contentStart = $contentEnd = 0;
while (false !== ($contentStart = strpos($str, $start, $startFrom))) {
$contentStart += $startDelimiterLength;
$contentEnd = strpos($str, $end, $contentStart);
if (false === $contentEnd) {
break;
}
$contents[] = substr($str, $contentStart, $contentEnd - $contentStart);
$startFrom = $contentEnd + $endDelimiterLength;
}
return $contents;
}
$data = getContents($content, '<div class="photo_s">', '</div>');
foreach($data as $value){
echo $value;
}
output:
Example Text
Example Text
Example Text1
Example Text1
Using Jquery:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="content"></div>
<script>
var href = 'testing.php';
$.ajax({
url:href,
type:'GET',
success: function(data){
var str="";
$(data).each(function(key,value){
if(this.className == "photo_s"){
str +=typeof value.innerHTML != 'undefined' ? value.innerHTML :"";
}
});
$('#content').html(str);
}
});
</script>
output:
Example Text
Example Text
Example Text1
Example Text1
test case testing.php:
<div class="photo_s">
<a href="">
<img title="" src="" alt="" /><br>Example Text <br>Example Text </a>
</div>
<div class="photo_s123">
<a href="">
<img title="" src="" alt="" /><br>Example Text123 <br>Example Text123 </a>
</div>
<div class="photo_s">
<a href="">
<img title="" src="" alt="" /><br>Example Text1 <br>Example Text1 </a>
</div>