Find us on twitterLike us on facebook
View Portfolio

PHP Library

Support Us

CSS Library

How do I replace part of a string in PHP | DevSocial.net How do I replace part of a string in PHP | DevSocial.net

free php scripts



Listings

How do I replace part of a string in PHP

How do I replace part of a string in PHP

 
 
 

Simply use str_replace:

$text = str_replace(' ', '_', $text);

You would do this after your previous substr and strtolower calls, like so:

$text = substr($text,0,10);
$text = strtolower($text);
$text = str_replace(' ', '_', $text);

If you want to get fancy, though, you can do it in one line:

$text = strtolower(str_replace(' ', '_', substr($text, 0, 10)));

$string = "this is the test for string." ; $string = str_replace(' ', '_', $string); $string = substr($string,0,10); var_dump($string);



Views: 943 / Downloads: 156 | Price: $0 | PHP / PHP Functions
Status:

|

You have no Listings. Create Listing.


Buy Ready made Web Apps  Buy Ready made Web Apps


Website Ranking Tools

classifieds24.net classifieds24.info classifieds24.org nywds.com https://www.globalclassifieds.org/ domainpaid.net devsocial.net paystopost.com paystopost.org https://www.101now.com https://www.newyorkconstructionco.com paystopost.org https://www.hirepros.org https://www.hirepros.info
EST: 2012 | © 2025 Devsocial.net | All Rights Reserved. [ + ][ y ]
SHARE:

Facebook

Twitter