Problem with PHP string functions

Problem with PHP string functions

Posted by: raddevon
Posted on: 2008-09-23 09:17:00

I'm trying to muck around with some strings in PHP in my Wordpress theme. Can anyone imagine why this code wouldn't work?

<?php $str = the_title(); $str = strtolower($str); $str = str_replace(" ","-", $str); echo $str; ?>

I'm taking the page title, converting it to lower case, and replacing strings with hyphens. I haven't tested with any pages with spaces yet. The page title is echoed, but it seems as if the strtolower function has not run on the string. Any help is greatly appreciated.

Re: Problem with PHP string functions

Posted by: silkrooster
Posted on: 2008-09-23 16:19:00

I think what I would do is rename each string variable then echo the variables to check the values. My guess it the_title() does not have a value or it is an array.

My website

Tags: muck