etrader
-
Posts
315 -
Joined
-
Last visited
Never
Posts posted by etrader
-
-
Thanks! It helped a lot
-
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>
-
base64_encode is a perfect standard php encoding, but this produces = most of times. Is there an alternative making the encode by alphanumeric only?
-
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: ..... "
-
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 )?
-
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 ?
-
I mean the root folder of the domain folder as /public_html/mysite.com/
-
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?
-
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?
-
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 !@#$%^&*()":;' ?
-
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. :-\
-
Perfect solution
-
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.
-
Thanks it works perfectly!
-
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
-
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.
-
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.
-
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?
-
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);
-
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.
-
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?
-
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.
-
As I said, it was crude... But surely you can work with it? Or are you expecting other people to do most of the work for you?
No, I can replace "-"s by means of str_replace; but I am not sure if it is the simplest way to do so.
-
<?php $subject = "word1-word2-word3-word4-word5-word6-word7"; $pattern = "/(\w*-){5}/i"; preg_match($pattern, $subject, $matches); echo $matches[0]; ?>
As I tried, this returns nothing.
Deleting urls from a string
in PHP Coding Help
Posted
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"