Jump to content

etrader

Members
  • Posts

    315
  • Joined

  • Last visited

    Never

Everything posted by etrader

  1. I have a string containing long text, which contains urls in the form of example.com or www.domain.com (simple plain text, not html links). How I can delete all of them. I need a php regex to delete all terms containing ".com"
  2. I want to create a xml-based rss which is readable by RSS readers <?xml version="1.0"?> <rss version="2.0"> <channel> <title>Title</title> <link>http://link.com/</link> How I can write php strings from a php file into it as <item> <title><? echo $title ?></title> <link><? echo $link ?></link> <description><? echo $description ?></description> <pubDate><? echo $date ?></pubDate> <guid><? echo $id?></guid> </item>
  3. base64_encode is a perfect standard php encoding, but this produces = most of times. Is there an alternative making the encode by alphanumeric only?
  4. Thanks for your suggestion, but this phrase is within a long string; the string is not limited to this phrase. I need a replacing method to look for "Note: ..... "
  5. I have phrases in a string with the structure of "Note: some description" I want to replace "Note with (, but how can I replace the second " with )?
  6. get_meta_tags fairly gets all meta tags within the html head starting by <meta .... Is it possible to get "<link rel=..."s within the html head too ?
  7. I mean the root folder of the domain folder as /public_html/mysite.com/
  8. I put the javascript code of ad into a file named ad.html, then call it in php by $ad = file_get_contents("http://mysite.com/ad.html"); echo $ad; But this does not work for file_get_contents("/ad.html") Is there a way to avoid writing the domain name, and just getting the ad from the file in the root folder?
  9. Is there a way to catch the target of a redirecting url? For example, http://tinyurl.com/KindleWireless redirects to http://www.amazon.com/Kindle-Wireless-Reading-Display-Globa lly/dp/B003FSUDM4/ref=amb_link_353259562_2?pf_rd_m=ATVPDKIK X0DER&pf_rd_s=center-10&pf_rd_r=11EYKTN682A79T370AM3&pf_rd_ t=201&pf_rd_p=1270985982&pf_rd_i=B002Y27P3M How to catch the final url in php and echo it as a string?
  10. There are good ways to keep only English characters in a string. But what is the easiest way to keep all alphabetic characters (whether in English or other languages like Russian, Japanese, etc) by removing all sign characters like !@#$%^&*()":;' ?
  11. I used the following code to convert the length in seconds to min:second format $sec=$duration % 60; if ($sec=="0"){ $min=$duration/60; $duration=''.$min.':00'; }else{ $min=(($duration-$sec)/60); $duration=''.$min.':'.$sec.''; } everything is OK, but it shows 35:5 instead of 35:05. I mean it disregards the first 0 when the second is 1-digit. :-\
  12. I want to get suggested keywords from yahoo api service. When xml file is empty (no keyword), it gives error. To resolve this problem I used this code: if (file_exists('http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=YahooDemo&query=Madonna&results=2')) { $xmlmetades = simplexml_load_file('http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=YahooDemo&query=Madonna&results=2'); } Since it is not a normal .xml file, it is always considered no file, and return nothing.
  13. I have a string taken from an array in a foreach with the following structure /MAINWORD/something/else ...... I want to catch only MAINWORD and remove everything else
  14. I have a foreach parsing as foreach ($posttags as $tag) { $test = $tag->name; $pattern = "/something/"; if(preg_match($pattern, $test)) { $test2 = "$test is $test"; echo $test2; } } I selected those containing a given word, but I do not know how to remove duplicates to have uniqueness. I was unable to use array_unique, as I am within a foreach loop.
  15. I have a file containing lines (I mean elements separated by <br>). How I can put these lines into an array, but only those which has a given phrase. Example file This is the first line<br> Second line is here<br> something else<br> something else<br> something more<br> I want to catch only lines which contain the word "something" and make an array.
  16. Youtube has an advanced api to deliver xml; but when I try to parse its xml, it is not well-defined. I want to get "average rating" for a given video, but simple xml load disregard this section: $xml = simplexml_load_file('http://gdata.youtube.com/feeds/mobile/videos/wZ252E282go'); print_r($xml); How can I put the value of "average rating" into an string to echo?
  17. I tried to parse wikipedia xml api by different methods, but I was unsuccessful :'( Even the curl method did not work $url = "http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Wikipedia&rvprop=timestamp|content"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HTTPGET, TRUE); curl_setopt($ch, CURLOPT_POST, FALSE); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_NOBODY, FALSE); curl_setopt($ch, CURLOPT_VERBOSE, FALSE); curl_setopt($ch, CURLOPT_REFERER, ""); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_MAXREDIRS, 4); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; he; rv:1.9.2. Gecko/20100722 Firefox/3.6.8"); $page = curl_exec($ch); $xml = simplexml_load_string($page); print_r($xml);
  18. Actually, I want to shorten a string which is incorporated into a url. It makes the url too long. I want to make the string shorter to have a shorter url. Then when going to the url, we can GET and decode the string for further processing.
  19. I want to encode a long string, and wish to make it shorter. base64_encode is very handy but it makes the string length longer. Is there an alternative to do the encoding/decoding with shorter encoded string length?
  20. This works well, only when the number of words are higher than the limit. If the number of words are originally lower than the limit, it returns nothing.
  21. No, I can replace "-"s by means of str_replace; but I am not sure if it is the simplest way to do so.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.