Search the Community
Showing results for tags 'iframes'.
-
Hi, I am still learning PHP and given some HTML I am trying to extract all links and iframes from the HTML and append them to a different string. I am still learning PHP so I am not sure if how I am checking that the returned array has values (isset) or if I should be appending strings together (.) is correct The code that I have so far is function GetLinksIFrames($content) { $innerContent =''; $regex_pattern_links = "/<a href=\"(.*)\">(.*)<\/a>/"; preg_match_all($regex_pattern_links,$content,$matches); for ($i = 0; $i < count($matches); $i++) { if(isset($matches[0][$i]))// Is this correct? { $innerContent = $innerContent.$matches[0][$i]." "; // Is this how to append a result to an existing string? } } $regex_pattern_iframe = "/<iframe src=\"(.*)\">(.*)<\/iframe>/"; preg_match_all($regex_pattern_iframe,$content,$matches); for ($i = 0; $i < count($matches); $i++) { if(isset($matches[0][$i])) { $innerContent = $innerContent.$matches[0][$i]." "; } } return $innerContent; } Any help appreciated Thanks Mark
-
Heya all, So I've completed my first semester on PHP programming. I got an A, ./flex ! Anyhow, I'm trying to take what I've learned and practice with it. I ran into a bit of a road block and after spending a day trying to figure it out I decided it was time to come ask the pros 8D. I have some thumbnails inside a folder that are dynamically generated when a user visits a page. What I am trying to do with the thumbnails is have them, when clicked, change the photo inside of an iframe. Unfortunately this is not working. Well, enough gabbing. Here's the code that is the culprit of my problem. I think. <?php require ('includes/photo_functions.php'); $images_dir = "uploads/" . $_SESSION['username'] . "/photos/"; $thumbs_dir = "uploads/" . $_SESSION['username'] . "/photos/thumbs/"; $thumbs_width = 200; $images_per_row = 3; /** generate photo gallery **/ $image_files = get_files($images_dir); if(count($image_files)) { $index = 0; foreach($image_files as $index=>$file) { $index++; $thumbnail_image = $thumbs_dir.$file; if(!file_exists($thumbnail_image)) { $extension = get_file_extension($thumbnail_image); if($extension) { make_thumb($images_dir.$file,$thumbnail_image,$thumbs_width,$extension); } } echo '<a href="#null" onClick="inner_Iframe.location="',$images_dir.$file,'" class="photo-link"><img class="photo-link" src="',$thumbnail_image,'" /></a>'; if($index % $images_per_row == 0) { echo '<div class="clear"></div>'; } } echo '<div class="clear"></div>'; } else { echo '<p>There are no images in this gallery.</p>'; } ?> Any help would be appreciated. I'm hoping this is a logical error or perhaps poorly placed quotations? Best Regards, Nightasy