brad45429 Posted February 8, 2007 Share Posted February 8, 2007 Everything is working fine with your BEAUTIFUL php script that you wrote FOR ME. I came across a problem today though. http://www.xenianaz.org/blogs/ One of my guys blogged today and posted a photo at the beginning of his blog post, and ONLY the image he posted shows up on my parsed, outputed feed. Is there a way to modify the script to NOT include images? Sorry man. YOU ROCK! Here is the script again if you need to see it.... <?php /** * Replace stripos() * * @category PHP * @package PHP_Compat * @link http://php.net/function.stripos * @author Aidan Lister <aidan@php.net> * @version $Revision: 1.9 $ * @since PHP 5 * @require PHP 4.0.1 (trigger_error) */ if (!function_exists('stripos')) { function stripos($haystack, $needle, $offset = null) { if (!is_scalar($haystack)) { trigger_error('stripos() expects parameter 1 to be string, ' . gettype($haystack) . ' given', E_USER_WARNING); return false; } if (!is_scalar($needle)) { trigger_error('stripos() needle is not a string or an integer.', E_USER_WARNING); return false; } if (!is_null($offset) && !is_numeric($offset)) { trigger_error('stripos() expects parameter 3 to be long, ' . gettype($offset) . ' given', E_USER_WARNING); return false; } // Manipulate the string if there is an offset $fix = 0; if (!is_null($offset)) { if ($offset > 0) { $haystack = substr($haystack, $offset, strlen($haystack) - $offset); $fix = $offset; } } $segments = explode(strtolower($needle), strtolower($haystack), 2); // Check there was a match if (count($segments) == 1) { return false; } $position = strlen($segments[0]) + $fix; return $position; } } define('MAGPIE_DIR', '../blogs/magpie/'); require_once(MAGPIE_DIR.'rss_fetch.inc'); $rss = fetch_rss('http://xenianaz.org/blogs/jim/atom.xml'); $item = $rss->items[0]; //this changed a bit. It's not $content anymore $allContent = $item['atom_content']; //first 200 characters, some word might be chopped off here $content = substr($allContent, 0, 200); //whatever is being hidden, with possible chopped in half word at beginning $remainingContent = substr($allContent , 200, (strlen($allContent) - 200)); //might want to check if a space is the last character of the current content //if so, no words were chopped in half if(substr($content, (strlen($content) - 1), 1) == " ") { //this is where I made my mistake $remainingContent = false; } //if there were less than 200 characters to begin with, skip the following if($remainingContent && strlen($remainingContent) > 0) { $spacePosition = stripos($remainingContent, " "); //position of next space/word break if($spacePosition) $content .= substr($remainingContent, 0, ($spacePosition + 0)); } else { $content .= $remainingContent; } echo "<p>$content...</p>\n"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/37676-ultrus-help-pleaserss-parsing-2/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.