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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by Jessica
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.