flavaflav37 Posted October 17, 2012 Share Posted October 17, 2012 Hi, I have a piece of code - <?php echo $data['text_skill_one']; ?> That is basically outputting an option from my Wordpress theme option panel, so the output from the above would be - HTML 5. What I would like to do is make this output all lowercase with the spaces removed so we have - html5 The reason being that I would like to add it as a .class name in my php file. The code I have attempted already is below - <?php $data = 'text_skill_one'; $string = $data; $output = strtolower($str); echo($string) ?> But what this is currently outputting is - text_skill_one I would like it to output the option that has been chosen in the Theme Options panel (lowercase with spaces removed) Any tips would be greatly appreciated. Thanks in advance Quote Link to comment Share on other sites More sharing options...
trq Posted October 17, 2012 Share Posted October 17, 2012 Have a look at your code. It doesn't make much sense. Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 17, 2012 Share Posted October 17, 2012 In addition to your code being nonsensical, the string 'text_skill_one' already IS lowercase with no spaces. I'm not sure what you expect it to look like, it's already meeting the criteria. Quote Link to comment Share on other sites More sharing options...
flavaflav37 Posted October 17, 2012 Author Share Posted October 17, 2012 Have a look at your code. It doesn't make much sense. Hence why I'm here asking for advice Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 17, 2012 Share Posted October 17, 2012 echo strtolower(str_replace(' ', '', $data['text_skill_one'])); Maybe. Who knows. Your examples conflict. Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 17, 2012 Share Posted October 17, 2012 That thorpe meant is that your example code of what you want makes no sense at all, you say you want to echo a string lowercase with no spaces, then show how to access an array key using a key which is lowercase with no spaces, then show code which echoes the key (instead of using it as an array key) while simultaneously overwriting the array you showed in your first example. Quote Link to comment Share on other sites More sharing options...
flavaflav37 Posted October 17, 2012 Author Share Posted October 17, 2012 That thorpe meant is that your example code of what you want makes no sense at all, you say you want to echo a string lowercase with no spaces, then show how to access an array key using a key which is lowercase with no spaces, then show code which echoes the key (instead of using it as an array key) while simultaneously overwriting the array you showed in your first example. Thanks, please read my post a little more. I think I explain how I do not want to echo text_skill_one verbatim, but what text_skill_one outputs (a meta field), which will have the input HTML 5. Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 17, 2012 Share Posted October 17, 2012 (edited) And you clearly already know how to do that. Hi, I have a piece of code - <?php echo $data['text_skill_one']; ?> That is basically outputting an option from my Wordpress theme option panel, so the output from the above would be - HTML 5. Why you would attempt to alter the key string instead of the value in the array is the question. You also overwrote your array. Dan also GAVE you the answer already. What is the problem? Edited October 17, 2012 by Jessica Quote Link to comment Share on other sites More sharing options...
ManiacDan Posted October 17, 2012 Share Posted October 17, 2012 Hi, please go read my post a little more, it contains an answer as well as an explanation of why your post cannot be answered (despite me answering it) Quote Link to comment Share on other sites More sharing options...
flavaflav37 Posted October 17, 2012 Author Share Posted October 17, 2012 Thanks guys. Go a little gentler next time eh? Quote Link to comment Share on other sites More sharing options...
Christian F. Posted October 17, 2012 Share Posted October 17, 2012 There is no gentle or harsh tones in this thread, just a listing of facts. To understand the context of tech help fora a bit more, I recommend that you read this article. It'll also help you gain help more efficiently and accurately. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.