Jump to content


Photo

change string in php (fill spaces)


  • Please log in to reply
2 replies to this topic

#1 thyscorpion

thyscorpion
  • Members
  • PipPipPip
  • Advanced Member
  • 46 posts

Posted 26 July 2006 - 08:55 AM

hi i have a string variable say "alpha beta gama"and i need to change it to "alpha-beta-gama.txt" using php..
which set of functions will help me achieve that? ???
i need to fill the spaces with a '-' and put a .txt at the end.
:-\

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 26 July 2006 - 09:34 AM

<?php
$str = "alpha beta gama";
$new = str_replace(" ","-",$str).".txt";
?>


#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 26 July 2006 - 09:54 AM

Incase you dont understand caternation's


$str = "alpha beta gama";

$new = str_replace("alpha beta gama","alpha-beta-gama.txt",$str);

echo $new;


Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users