-
Posts
218 -
Joined
-
Last visited
Posts posted by gdfhghjdfghgfhf
-
-
-
Have a look at preg_replace(),
http://uk3.php.net/manual/en/function.preg-replace.php
An expression like this should suffice (from :
// Regex taken from: http://flanders.co.nz/2009/11/08/a-good-url-regular-expression-repost/ $regex = "/(?#Protocol)(??:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(??:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(??:(?:\/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|\/)+|\?|\#)?(?#Query)(??:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:\#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?/"; $newdata = preg_replace($regex,"(link)",$data); // Where $data is your content you want to replace links for
-cb-
Have you even tried this script i put together for you?
It does exactly what you want.
-cb-
i have a problem with this script
for example, this text:
[DL]http://www.megaupload.com/?d=QI29F7AJ[/DL]maxi repressage de 1982
01 - couleurs sur paris.mp3
02 - maximum.mp3
03 - tout ce fric.mp3
04 - poupee de cire.mp3
05 - piano dub.mp3
AlbumArtSmall.jpg
Folder.jpg
OBERKAMPF-LP-Couleurs5tvert.jpg
will turn into:
[DL](link)[/DL]maxi repressage de 1982
(link)3
(link)3
(link)3
(link)3
(link)3
AlbumArtSmall.jpg
Folder.jpg
OBERKAMPF-LP-Couleurs5tvert.jpg
i want to convert only the links that start with http://
but the script thinks the list of the mp3 names are links
any help would be appreciated!
-
i want to shorten only the big words, not to shorten a whole string
example:
"this is a text with small words and a big word like " anticonstitutionally " and i want to shorten words that exceed 10 characters"
would result in
"this is a text with small words and a big word like " anticonsti" and i want to shorten words that exceed 10 characters"
-
is there a function in php that could shorten the words if the words exceed 15 characters ??
thanks
-
thanks a lot !!! it's working !!
-
Hi,
I ran the script and it worked perfectly.
$url = "http://www.link.com This is a test and hello my name is bob"; $result = xcleaner($url); print $result; function xcleaner($url) { $U = explode(' ', $url); $W =array(); foreach ($U as $k => $u) { $W = explode('.', $u); if (stristr($u,'http') || (count($W) > 1 && $W[1] != "") || (count($W) > 2)) { unset($U[$k]); return implode(' ',$U); } } return implode(' ',$U); }
yes you are right... i just realized the given example will work
but if i try with this text it will not work:
http://www.dailymotion.com/video/x4o...me-french_newshttp://www.dailymotion.com/video/x4o...french-p2_news
http://www.dailymotion.com/video/x4o...french-p3_news
http://www.dailymotion.com/video/x4o...french-p4_news
http://www.dailymotion.com/video/x4s...french-p5_news
Super Size Me est un film documentaire américain réalisé par Morgan Spurlock. Le journaliste décide de se nourrir exclusivement chez McDonald’s pendant un mois et enquête à travers les États-Unis sur les effets néfastes du fast-food et de la célèbre chaîne spécialiste du hamburger, qui entraînent l'accroissement de l'obésité.
i don't understand where the problem comes from..
ungovernable,If I understand your request correctly, the following code produces what you want:
link hello my name is bob
http://link.com hello my name is bob
actually, i want to replace ALL links with the text "link"
so something like
http://www.awebsite.com/hello/blabla/hi.php would be replaced by "link"
-
hello,
i am using this script to remove links in a text:
function xcleaner($url){
$U = explode(' ', $url);
$W =array();
foreach ($U as $k => $u)
{
$W = explode('.', $u);
if (stristr($u,'http') || (count($W) > 1 && $W[1] != "") || (count($W) > 2))
{
unset($U[$k]);
return implode(' ',$U);
}
}
return implode(' ',$U);
}
the problem is that it will also remove the first word after the link
example:
http://www.link.com hello my name is bobwould result in:
my name is bobhow can i fix this ?
also, i would like to replace the links with the word "(link)" instead of just removing everything
thanks a lot!
-
ok so here is my situation:
i have a t-shirt shop at spreadshirt.com, but it is in french
i'm trying to translate the main page in english
so i use file_get_contents() to display the page, and then i use str_replace() to translate the words
i can translate all the words but when i try to replace a word with accents it doesn't work...
how to solve this problem ?
-
thanks
-
Well i'm looking to do something i usually could do easily using COUNT and GROUP BY if it was a sql query... But this time i'm working with an array...
so i have an array that looks like this
$array( "dog", "cat", "dog", "fish", "horse", "cat", );
First i want to group together the duplicate entries. And then, i want to list the number of times the item was found in the array
with the above example, i would be expecting a result like this:
$array( "dog (2 results)", "cat (2 results)", "fish (1 results)", "horse (1 results)", );
From what i have read on google i can group together the duplicate entry with array_unique() but i have no idea how i can list the number of times this item was found in the array
thanks for helping me!!
-
Damn, sorry
here is the query with the GROUP BY request
$query = "SELECT search_time, search_keywords FROM phpbb_popsearch GROUP BY search_keywords ORDER BY search_time DESC limit 35";So it will group together entries with the same name, but it will lose its original position ! (i.e. first entries will not be first anymore once its grouped)
-
i usually use this query to display the last 10 entries from a sql table:
$query = "SELECT search_time, search_keywords FROM phpbb_popsearch ORDER BY search_time DESC limit 35";
as you can see it will order the results by "search_time" so the latest entries are listed first
normally the result would be something like this:
new entryduplicate
another entry
bla bla
348237
543543
duplicate
but now i just want to include a "GROUP BY" in this sql request
$query = "SELECT search_time, search_keywords FROM phpbb_popsearch ORDER BY search_time DESC limit 35";
but with the GROUP BY my sql query isn't ordered correctly anymore.
the result would be something like this:
new entryanother entry
bla bla
348237
543543
duplicate
notice the "duplicate" entry was grouped together, but it's not in the second first position anymore ???
i was expecting a result like this:
new entryduplicate
another entry
bla bla
348237
543543
Since entry called "duplicate" is the second last added entry....
i hope you understand what i mean ^^
thanks for help
-
seems to be working, thanks!
-
ok so i have this very simple code:
$query = "SELECT search_keywords, COUNT(search_keywords) AS counter FROM phpbb_popsearch GROUP BY search_keywords ORDER BY counter DESC limit 5"; $res = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($res)) { $term = $row["search_keywords"]; echo $term; }
phpbb_popsearch is a table where i put the last search terms used in my forum search engine
this code will group together the same terms and list the 5 most popular terms
my problem is that the results will be ordered by "counter" which is the number of time a term has been found.
I want to get the 5 most popular results AND THEN, AFTER, list the results alphabetically
if i sort the results alphabetically right in the sql query (replacing "ORDER BY counter" by "ORDER BY search_keywords") it will not work correctly because it will not get the 5 most popular terms but just the 5 first terms, alphabetically sorting them and ignoring the number of times the term has been found
thanks for help !!
-
Yeah but to me W3C was a source as serious as the php manual, but oh well...
But if old browsers are still limited to 100 chars then my script wont be compatible with old browsers??
-
damn.... actually i didnt try it because i found a lot of pages saying it is limited to 100 chars on google....
like this page (first result in google when i type $_GET)
http://www.w3schools.com/PHP/php_get.asp
"Note: The get method is not suitable for large variable values; the value cannot exceed 100 characters."
ill try it now!
-
here's an example:
file.php <?php $url = $_GET("url"); echo "<meta http-equiv=\"refresh\" content=\"1; URL=$url\">"; ?>
now if i access "file.php?url=http://blabla.com" using a url longer than 100 characters it won't work
-
i think you didn't understand what i want to do
i want to make a script that i can access just like anonym.to
and if i access this URL, then it will display some text and redirect 5 seconds after
my only problem is that i can't use $_GET because the limit is 100 characters
-
Ok basically what i want to do it a redirection system with a temporary page.....
just like anonym.to
if you go to
http://anonym.to/http://www.phpfreaks.com it will display a temporary page then redirect you to phpfreaks.com
normally i would just do that with $_get but the damn limit of characters is only 100, so it will not work with long URL
how exactly is anonym.to working ? It looks like a htaccess redirect, but how can you transmit values through htaccess then take back this value in your php code just like $_GET does
any suggestions?
btw i want to avoid using $_POST if possible...
-
though I'm not convinced it will work as their are no lasy quantifiers I think it may grab multiple urls in one.
I'm not sure what you mean.... how can i add that lazy quantifier ?
-
unless i am doing something wrong, this is not working
-
i have one more problem
this code will not replace links with single quote, like this:
-
That example isn't matched by the pattern. Your pattern requires a space after the closing double bracket, which there isn't in the example.
Damn, i'm an idiot! I didn,t pay attention to the space.
Thanks a lot
Oh and how about stop converting <a href=""></a> to
would it be very hard??
-
actually, here is my real input (with the problematic images):
http://www.punksandskins.com/crawler1.php
it is a rss feed, i'm trying to take the html content with file_get_contents, then convert the html to bbcode with the code i posted above
help me fix this script please
in PHP Coding Help
Posted
bump!
here's another example of a text that will be messed up once parsed with the function given in ChemicalBliss's post