Re: [PHP] replace question
- Original Message - From: WebDev [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, March 12, 2003 1:24 AM Subject: Re: [PHP] replace question Hello How could I know recognize a URL in $a $a contains often a URL htp://www.mysite.com but as well more text how is it possible now to recognize a URL could be in $s and if so we make it a actual html link, for the end user... // start $a= str_replace(Dog, Cat, $b); $a_tooklinkout = if ($a == foundlink) { echo a href=\$a_tooklinkout $c/a; } else echo $a; // end anybody has a tip for me .. Thank you all -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace question
- Original Message - From: WebDev [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, March 12, 2003 1:24 AM Subject: Re: [PHP] replace question Hello How could I know recognize a URL in $a $a contains often a URL htp://www.mysite.com but as well more text how is it possible now to recognize a URL could be in $s and if so we make it a actual html link, for the end user... // start $a= str_replace(Dog, Cat, $b); $a_tooklinkout = if ($a == foundlink) { echo a href=\$a_tooklinkout $c/a; } else echo $a; // end anybody has a tip for me .. Thank you all
[PHP] replace question
Hello all how do we replace this out of an array element ~nl~ with nbsp; Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] replace question
how do we replace this out of an array element ~nl~ with nbsp; How about str_replace()? Or are you talking about replacing that value in each and every element in the array? If so, use array_walk() or loop through the array and use str_replace(). ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace question
(This is more info on the question I asked before) Here's the text file (text.txt): This is a test of the templating program. Here's hoping it's working! John Smith Here's one line from the CSV file (new_data.csv): John,Smith,4770 Rosepetal Ct., Richmond, VA 22032 USA,(703) 978-4472,0/0/00, And here's the code I have (merge.php): 1 ? 2 $row = 1; 3 4 $text = fopen(text.txt, r); 5 $merged = fopen(merged_text.html, w); 6 $fp = fopen(new_data.csv, r); 7 8 $filecontents = fread($text,filesize(text.txt)); 9 10 while ($data = fgetcsv ($fp, 1000, ,)) { 11 $num = count ($data); 12 $row++; 13 for ($c=0; $c $num; $c++) { 14 $fullname = $data[0] . . $data[1]; 15 $newfullname = a href=.$fullname..$fullname./a; 16 $newfilecontents = str_replace($fullname,$newfullname,$filecontents); 17 18 fwrite($merged,$newfilecontents); 19 } 20 } 21 echo nl2br($newfilecontents); 22 // fwrite($merged,$newfilecontents); 23 fclose ($fp); 24 fclose ($merged); 25 fclose ($text); 26 ? Josh Miguel Cruz wrote: On Sun, 5 May 2002, Josh Valerie McCormack wrote: I'm iterating through a CSV file pulling in rows as arrays with fgetcsv and I'd like to search for patterns made up of the first two array items of each row with a space between them in a text file, and make them into links. I can't figure out how to do this, could someone help? How about posting a sample row or two along with how you want the data to appear after the transformation? miguel
[PHP] replace question
I'm iterating through a CSV file pulling in rows as arrays with fgetcsv and I'd like to search for patterns made up of the first two array items of each row with a space between them in a text file, and make them into links. I can't figure out how to do this, could someone help? Josh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] replace question
Are you having trouble pulling the data out of the file, or creating the link? Do you want a link created for every row? What is the makeup of the file? Is array[0] the URL, and array[1] the desription? If it's just the link you need, that's easy... echo a href=' . $array[0] . ' . $array[1] . /a; ---John Holmes... -Original Message- From: Josh Valerie McCormack [mailto:[EMAIL PROTECTED]] Sent: Sunday, May 05, 2002 8:23 AM To: PHP-General Subject: [PHP] replace question I'm iterating through a CSV file pulling in rows as arrays with fgetcsv and I'd like to search for patterns made up of the first two array items of each row with a space between them in a text file, and make them into links. I can't figure out how to do this, could someone help? Josh -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] replace question
On Sun, 5 May 2002, Josh Valerie McCormack wrote: I'm iterating through a CSV file pulling in rows as arrays with fgetcsv and I'd like to search for patterns made up of the first two array items of each row with a space between them in a text file, and make them into links. I can't figure out how to do this, could someone help? How about posting a sample row or two along with how you want the data to appear after the transformation? miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php