Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-01-2010, 02:05 PM   PM User | #16
ShannenS
New Coder

 
Join Date: Apr 2010
Posts: 24
Thanks: 1
Thanked 0 Times in 0 Posts
ShannenS is an unknown quantity at this point
Exactly the same as Phil posted but changed the file name.
PHP Code:
<?php

$file 
"list.txt";
$srt file_get_contents($file);
 
 
$array preg_match_all("#<li><a\s+name=\"(?:[^\"]+)\"\s?>([^<]+)</a></li>#is"$str$matches);

 foreach( 
$matches[1] as $key => $inner_text ) {
     
$url_insert urlencode$inner_text );
     
$str str_replace($matches[0][$key], "<li><a href=\"http://www.google.com.au/search?q=" $url_insert "\">" $inner_text "</a></li>"$str); 
 }
 
 
$array preg_match_all("#<li>([^<]+)</li>#is"$str$matches); 
 
 foreach( 
$matches[1] as $key => $inner_text ) {
     
$url_insert urlencode$inner_text );
     
$str str_replace($matches[0][$key], "<li><a href=\"http://www.google.com.au/search?q=" $url_insert "\">" $inner_text "</a></li>"$str); 
 }
 
 echo 
$str;
 
?>
ShannenS is offline   Reply With Quote
Old 05-01-2010, 02:05 PM   PM User | #17
Phil Jackson
Senior Coder

 
Join Date: Aug 2009
Location: Mansfield, Nottinghamshire, UK
Posts: 1,547
Thanks: 57
Thanked 148 Times in 147 Posts
Phil Jackson is on a distinguished road
hehehe im a monkey

$srt = file_get_contents($file);
__________________
Website Design Mansfield
PHP Code:
function I_LOVE(){function b(&$b='P'){$b.='P';}function a($_){return $_++;}$b='P';define("B",'H');b($b=implode('',array($b=a($b),$b=a(B))));b($b);return $b;}
echo 
I_LOVE(); 
Phil Jackson is offline   Reply With Quote
Old 05-01-2010, 02:09 PM   PM User | #18
ShannenS
New Coder

 
Join Date: Apr 2010
Posts: 24
Thanks: 1
Thanked 0 Times in 0 Posts
ShannenS is an unknown quantity at this point
Oh right! I hate it when it's the simple things.
ShannenS is offline   Reply With Quote
Reply

Bookmarks

Tags
regex

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:31 AM.


Advertisement
Log in to turn off these ads.