Page 1 of 1

Working with simple STrings

Posted: Fri Dec 08, 2006 9:40 am
by orbstra
Hey I want to edit my string $url..

in this case $url is equal to 'admin/page/add'

I want to change $url to $url_bread and change the string to 'admin >> page >> add'

so to recap: I want to change

'admin/page/add'
for every '/' I want there to be ' >> '

thanks guys

Posted: Fri Dec 08, 2006 9:49 am
by Corvin
http://www.php.net/str_replace

Code: Select all

<?php
$url = "admin/page/add";
$url_bread = str_replace("/", " >> ", $url);
?>

Posted: Fri Dec 08, 2006 11:41 am
by orbstra
Works great! THANKS!

What if I wanted the first letters in $url variable to be capitalized

Posted: Fri Dec 08, 2006 11:44 am
by RobertGonzalez

Posted: Fri Dec 08, 2006 12:34 pm
by orbstra
That works great, but not completely.. I think this is the best I am going to get, but if it is possible, could I capitalize every first letter?
for instance

Original:

Code: Select all

"admin >> page >> add
With ucfirst():

Code: Select all

"Admin >> page >> add
What I hope is possible to do next:

Code: Select all

"Admin >> Page>> Add
THANKS!

PS: love this php community its been a big help, I will definetly help spread the word

Posted: Fri Dec 08, 2006 12:35 pm
by RobertGonzalez

Posted: Fri Dec 08, 2006 12:38 pm
by orbstra
Wait ignore that one!! Just figured it out

Code: Select all

guav_sys_url_name();
		global $url;
		$url_bread = str_replace("/", " >> ", $url);
		$url_bread = ucwords($url_bread);
		$url_bread = ucwords(strtolower($url_bread));
		echo '<small>' . $url_bread . '</small>';