Jump to content

Archived

This topic is now archived and is closed to further replies.

thyscorpion

change string in php (fill spaces)

Recommended Posts

hi i have a string variable say [b]"alpha beta gama"[/b]and i need to change it to [b]"alpha-beta-gama.txt" [/b] 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.
:-\

Share this post


Link to post
Share on other sites
[code]<?php
$str = "alpha beta gama";
$new = str_replace(" ","-",$str).".txt";
?>[/code]

Share this post


Link to post
Share on other sites
Incase you dont understand caternation's

[code]

$str = "alpha beta gama";

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

echo $new;

[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.