NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page i need help with string replace

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search
6 members in live chat ~  


Reply
 
LinkBack Thread Tools
Old 11-03-2011, 03:54 AM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: Mar 2005
Posts: 192
oberheimer is a jewel in the roughoberheimer is a jewel in the roughoberheimer is a jewel in the rough
 



i need help with string replace


Here is the code that i use


$rs_products_image_large=str_replace('images/','images/1_',$products_image_large);
$rs_products_image_large_1=str_replace('images/','images/1_',$products_image_large);

I want to change so the replaced image is products_image_large_1
instead of 1_products_image_large

But im not good at coding
__________________
clap.com clap - your music forum

---------------------------------------
BUYING LLL.com & Quality word.com
oberheimer is offline   Reply With Quote
Old 11-05-2011, 11:14 AM   #2 (permalink)
i love automation
 
xrvel's Avatar
Join Date: Nov 2007
Location: xrvel.com
Posts: 1,615
xrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant futurexrvel has a brilliant future
 





PHP Code:
<?php
function my_custom_replace($s$format) {
    
$base basename($s);
    
$dir dirname($s).'/';
    
$a explode('.'$base);
    
$ext array_pop($a);
    
$clean_file implode('.'$a);
????: NamePros.com http://www.namepros.com/programming/736268-i-need-help-with-string-replace.html
????: NamePros.com http://www.namepros.com/showthread.php?t=736268
    
$new_file sprintf($format$clean_file).'.'.$ext;
    return 
$dir.$new_file;
}

$products_image_large 'images/example/blue_shoes.jpg';
$rs_products_image_large my_custom_replace($products_image_large'%s_1');

echo 
$rs_products_image_large;
?>
Output :
Code:
images/example/blue_shoes_1.jpg
I hope it helps.
__________________
xrvel is offline   Reply With Quote
Old 12-02-2011, 09:22 AM THREAD STARTER               #3 (permalink)
NamePros Member
Join Date: Mar 2005
Posts: 192
oberheimer is a jewel in the roughoberheimer is a jewel in the roughoberheimer is a jewel in the rough
 



Thanks i will try that
__________________
clap.com clap - your music forum

---------------------------------------
BUYING LLL.com & Quality word.com
oberheimer is offline   Reply With Quote
Old 12-02-2011, 10:04 AM   #4 (permalink)
Freelance Web Designer
 
Janine's Avatar
Join Date: May 2006
Location: Philippines
Posts: 3,080
Janine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond repute
 



Cystic Fibrosis Save a Life
Originally Posted by oberheimer View Post
Thanks i will try that
Let us know if it worked or not.
Janine is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
[PHP] Trim a string by length Hitch CODE 9 02-18-2012 09:12 AM
$5 Domainer's Dompad v1.0 - Generate, Bulk replace, Add word before & after! tekz999 For Sale / Advertising Board 7 02-09-2011 09:36 PM
Easy Replace - the fast way to change items on multiple files deu12000 For Sale / Advertising Board 0 01-15-2006 09:25 PM
Suppose I have a string. And in it, PHP code that I WANT to be executed mholt Programming 4 09-04-2005 06:11 PM
Alternating string splits Outer Programming 1 08-11-2005 03:05 AM

 
All times are GMT -7. The time now is 02:49 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger