NameSilo

Just a little help.

SpaceshipSpaceship
Watch

abcde

Established Member
Impact
16
PHP:
<?php
	$cat=mysql_query("SELECT * FROM cate ORDER BY cate")or die(mysql_error());	
   while($rowcat=mysql_fetch_array($cat)){
   $adr=str_replace(" ","-",$rowcat['cate']);
   $adr=str_replace("A","a",$rowcat['cate']);
   $adr=str_replace("B","b",$rowcat['cate']);
     echo  "somehting here";
   }
?>

PHP:
   $adr=str_replace(" ","-",$rowcat['cate']);
   $adr=str_replace("A","a",$rowcat['cate']);
   $adr=str_replace("B","b",$rowcat['cate']);

Question is: How do I combine them 3 "str_replacement" into 1, or it's ok to leave it as it is.

Thanks
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
Try this:
PHP:
   $adr=str_replace("B","b",str_replace("A","a",str_replace(" ","-",$rowcat['cate'])));
 
1
•••
Thank you Jim.

here is what i found on google, and it works too:

PHP:
			$big = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","/","&","+"," ");
			$small = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","-","-","-","-");
			$adr=str_replace($big, $small, $rowpcat['cate']);
 
0
•••
if you wish to just convert uppercase to lowercase you can check strtoupper strtolower strtocamel
PHP: strtoupper - Manual


hope that can help.
 
0
•••
You might want to look at strtr also:

PHP: strtr - Manual

PHP:
$adr=strtr($rowcat['cate'], ' AB', '-ab');
 
1
•••
0
•••
Just in case you simply want to capitalize the first character of a string:
ucfirst
 
0
•••
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back