PHP - How To Do A Str_replace To A Content:encoded From An Rss Feed
<?php
// rss page - $feed_url = "http://blog.kyleramirez.com/feed/"; // Load XML. $xml = simplexml_load_file($feed_url); // How many items to display from the RSS Feed ... $count = 3; // Grabbing the NameSpace URI for "itms" and "content" ... foreach ($xml->channel->item as $item) { $ns_content = $item->children('http://purl.org/rss/1.0/modules/content/'); if($count > 0){ echo " <ul class=\"pageitem\"> <li class=\"textbox\"><span class=\"header\">{$item->title}</span> {$ns_content->encoded} </li> <li class=\"menu\"> <span class=\"name\"><a href='{$item->link}'>View</a></span></li></ul> "; }else{ Return; } $count--; } ?> Above is a snippet of code used to extract the content:encoded and title from my RSS feed. I am looking for a way to strip the content part of a few tags, namely style and size and width tags so that I can fit it into the mobile section of my website. The mobile site is m.kyleramirez.com. You will be able to see how the rss feed is implemented there. This shouldn't be that complicated. I was trying to the str_replace to do it but I'm not sure how to put it in there. Any ideas? {$ns_content->encoded} is where the entire post is showing up. How do I add a str_replace to that? Similar TutorialsHello, I am trying to export data from database. the exported data is creted with wrong encoding. I am using this code: header("Pragma: public"); header('Expires: '.gmdate('D, d M Y H:i:s').' GMT'); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); header("Content-Type: application/force-download;charset=utf-8; encoding=UTF-8"); header('Content-Disposition: attachment; filename="'.$newFile.'"'); header("Content-Transfer-Encoding: binary"); header('Content-Length: '.@filesize($path)); Please help with the encoding. Thanks. Hi guys, I'm parsing a bunch of html sources, some of them (a minority) contain base64 encoded URLs. At least 20-30 URLs per page. Some of the information I need is taken from the URLs. I'm looking for a way to parse these URLs without losing too much time (20-30 URLs per page and I need to parse about 10k pages daily). Should I regex each source individually for base64 encoded URLs and then decode them each time and isn't that going to take a lot of time/resources (especially considering it's only a minority that have the base64 URLs in them)? Or is there a better way to do it? Code snippets are absolutely welcome! Thank you in advance so I've been putting all of my php scripts to exe to protect some of the code I have written, say I write a simple loop script like below <?php $REPEAT = 1000; $ECHO = "CLUEL3SS"; for($cwb=1; $cwb!=$REPEAT; $cwb++) { echo "#$cwb: $ECHO\n"; } sleep(99999999); ?> Now how can I set the variable $REPEAT when the script is in .exe form and I cannot edit the code I have tried $REPEAT = fgets(STDIN); That doesnt seem to work though when I have 5+ variables to assign and I have an array set like like $Variable[] = 12345799; $Variable[] = 34324555; $Variable[] = 34289789; $Variable[] = 32899090; How can I use a text file to set these options? maybe have the variables assigned in a text file like Code: [Select] ; this is a comment, this will be ignored REPEAT : 1000 ; this is another comment, ignored also... ECHO : CLUEL3SS ; comment Variable : 3423423 Variable : 2903890 Variable : 3948903 Variable : 9823900 How would I have the php script read the text file in that format to set the variables? How can i check if a string is URL encoded or not using PHP Hello all, I have a script I have been working on that retrieves my email from my mail server using some of the imap_functions. Everything works fine except for the emails that were sent from my blackberry. I have done some research and it seem to be something to do with the encoding that the blackberry uses. I have found a little bit of code that I was hoping would solve the issue. My goal is to get the body content from email that was produced with my blackberry and put bits of this body into a database. Then I want to do a report from that database once a week. I have developed a script that will retrieve all other message except from my blackberry. Does anyone know how blackberry encodes their body content? jmr3460 Hey guys, I have a script that attempts to call the database of my forums to find the last games played on each of their xbox live profiles. However when it attempts to call the image, it encodes the url - so http://tiles.xbox.com/tiles/tT/MX/0mdsb2JgbA9ECgQJGgYfVlpWL2ljb24vMC84MDAwIAABAAAAAP04M6o=.jpg turns into http%3A%2F%2Ftiles.xbox.com%2Ftiles%2FtT%2FMX%2F0mdsb2JgbA9ECgQJGgYfVlpWL2ljb24vMC84MDAwIAABAAAAAP04M6o%3D.jpg which makes the URL not work anymore so the script gives an error. I've tried urldecode() on numerous variables and it won't work. If I call the variable for the image on the page that submits the form it returns a normal address. Anyone have any ideas? Thanks! Hey everyone... Been over a year or more since I have had seek help here but I have something that I just do not understand. I am submitting a from from one domain - www.mydomain.com - to a form handler on another domain - www.theirdomain.com all under https. The form data is getting to theridomain.com just fine, the other side is handling it properly and all is well there. The issue is they are taking the response they generate and shipping it out via cURL using the below (they were nice enough to share this with me). Code: [Select] $url = $_SESSION['request']['retUrl']; $fields = array( 'hash'=>rawurlencode($hash), 'responseText'=>rawurlencode($_SESSION['response']['responseText']), 'cid'=>rawurlencode($_SESSION['request']['cid']), 'name'=>rawurlencode($_SESSION['request']['name']), 'actCode'=>rawurlencode($_SESSION['response']['actCode']), 'apprCode'=>rawurlencode($_SESSION['response']['applCode']), 'Token'=>rawurlencode($_SESSION['response']['token']), 'req_number'=>rawurlencode($_SESSION['request']['req_number']), ); foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); if (isset($_SESSION['request']['Address1'])) { $Address = array( 'Address1'=>rawurlencode($_SESSION['request']['Address1']), 'Address2'=>rawurlencode($_SESSION['request']['Address2']), 'City'=>rawurlencode($_SESSION['request'][City']), 'State'=>rawurlencode($_SESSION['request'][State']), 'Zip'=>rawurlencode($_SESSION['request']['Zip']), 'Country'=>rawurlencode($_SESSION['request']['Country']), ); foreach($Address as $key=>$value) { $Address_string .= $key.'='.$value.'&'; } rtrim($Address_string,'&'); } $end = array( 'END'=>"END" ); foreach($end as $key=>$value) { $end_string .=$key.'='.$value; } rtrim($end_string,'&'); I have worked for almost a week and I CANNOT snag the incoming data! All I am trying to do is collect this and convert it into $_SESSION data for use on a success page. If any one has any thoughts or in site, please.... Friends, I developed a script in php & i tested the script before encoding & its working fine. After i encoded the script through ionCube PHP Encoder & uploaded in my server but the file shows only blank page. Its not executing after encoding. What is the problem ?? How to fix it ? Hello All, I'm using php to auto-insert variables into a canonical url within the <head>. Here is my code: <link rel="canonical" href="http://www.mysite.com/page.php?IT=<?php print $item; ?>&IT2=<?php print $desc; ?>" /> I used this to replace "+" with " ". <?php $desc = str_replace ("+"," ",$desc); ?> The problem is i use the variables in different sections of the page were I don't want the "+" to appear. I only want the "+" to appear in the canonical url space. I'm sure there is an easy way, but not for me So to sum up: I want srt_replace code to be incorporated into the <?php print $desc; ?> code ONLY. Thanks in advance for any help! $to_censor = array("f", "a", "e", "r", "c"); $new_censor = array("****", "****", "****", "****", "****"); $new = str_replace($to_censor, $new_censor, $description); Is it possible to do this without having to add a new **** in $new_censor when I add another censored word in $to_censor Hi... I read on php.net manual that its better to use str_replace than preg_replace. I used Code: [Select] $summary = clean($_POST['summary']); $summary = nl2br($summary); to convert the carriage return(is that the correct term?) to insert them into mysql. So naturally, i want them converted into <br> when i pull them from mysql. I used this: Code: [Select] $num_rows=mysql_num_rows($result); if($num_rows == 0){ } else{ for($x = 0; $x < $num_rows; $x++){ $row = mysql_fetch_assoc($result); $id = $row['id']; $position = $row['position']; $summary = $row['summary']; $order = array("\r\n", "\n", "\r"); $replace = '<br />'; $newstr = str_replace($order, $replace, $summary); But i got this error: Code: [Select] Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/...php on line 310 Is it a syntax error? Thanx in advance... I am trying to learn PHP and am a novice so please excuse the stupid question but I have researched and attempted to find a solution for this and cant. Hoping someone can help me. I have the following code I am using within a Wordpress template... Code: [Select] <?php if (function_exists('simple_feed_list')) : ?> <?php $title = get_the_title(); str_replace("+", " ", $title); simple_feed_list('http://www.amazon.com/rss/tag/'. str_replace(" ", "+", $title) .'/new/ref=tag_tdp_rss_new_man?tag=search-20','limit=5&desc=yes&nofollow=yes&more=no'); ?> <?php endif; ?> I am trying to make it produce a RSS feed url from amazon that looks like this: http://www.amazon.com/rss/tag/ipod ibuds/new/ref=tag_tdp_rss_new_man?tag=search-20 note the space between ipod and buds, that is what I am trying to accomplish. Right now the space is being changed I think to a + sign which breaks the feed if the search term is more than one word. Can anyone help me fix this? I have tried removing the string replace part, etc with no luck I sometimes have words thrown into my database with the following symbol: Code: [Select] … What I'm trying to achieve is this.. Anytime that symbol is found, replace it and all previous letters.. back to the first space encountered... with nothing. Make sense? If I had the sentence Code: [Select] "the lazy brown d..…, it should return for me "the lazy brown" If I was just replacing the weird code, it would be a simple str_replace, but not sure how to make the letters before the symbol (up to the first space) go away. Ideas? more test -- ================================================================== this mobile text message is brought to you by at&t How can I get the red part removed? I tried: $endings = array('\n--\n==================================================================\nthis mobile text message is brought to you by at&t'); $CONTENT = str_replace($endings,"",$CONTENT); i put it in an array because i'll have to add more things later I want to basically delete any word that ends with ... So.. If I have the following phrase: Elvis Pres... I want to remove the word Pres... entirely. Basically, something along the lines of... $myphrase = str_replace("Pres...",'',$myphrase); except that I never know what $myphrase will be, so the above won't work. Is it str_replace I need or something else? Hello friends, If we have link $x = "search engin"; <a href="google.com"><?=$x?></a> and we want to remove space btween (search engine) to be (search-engine) ineed we should use str_replace and we change the link to $manal = str_replace(" ", "-", trim($x)); <a href="google.com"><?=$manal?></a> It not working ? and only working if $manal = str_replace(" ", "+", trim($x)); why + not - ? and is there anyway else to replce space to - ? thanks How can I add str_replace(" ", "-") to the following line: Code: [Select] echo "<p>" . $_SERVER['SERVER_NAME'] . "/" . strtolower(stripslashes($row['name'])) .".php</p>"; I have a bunch of provinces being displayed and want to replace spaces with - (for example British Columbia turns into www.domain.com/british-columbia.php so I can link to this file). Hello. I am pulling data from a mysql table and want to replace some strings that may appear in the data. Is it possible to use str_replace to replace more than one value at a time? For instance, replace '+' with 'plus' AND '-' with 'minus'. This doesn't work but something like this -- str_replace($search1, $replace1, $subject1, $search2, $replace2, $subject2); Thanks for all help! |