Jump to content

How To Echo Option All Lowercase With Spaces Removed.


flavaflav37

Recommended Posts

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

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.

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.

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?

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.

Archived

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

×
×
  • Create New...

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.