Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8580265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:47:30+00:00 2026-06-11T20:47:30+00:00

I wan to write a function with switch() where I can pass option value

  • 0

I wan to write a function with switch() where I can pass option value for multiple object.

Code

<?php
function font_switch(){

    if ($option == get_option('fm_font_family')) {
        get_option('fm_font_family') ;
    } else if ($option == get_option('fm_font_family_text')) {
        get_option('fm_font_family_text') ;
    }

    switch($option){

        case 'Choose font family':
            return null;
            break;

        case 'Georgia, serif':
            return 'Georgia, serif';
            break;

        case 'Palatino Linotype, Book Antiqua, Palatino, serif':
            return 'Palatino Linotype, Book Antiqua, Palatino, serif';
            break;

        case 'Times New Roman, Times, serif':
            return 'Times New Roman, Times, serif';
            break;

        case 'Arial, Helvetica, sans-serif':  
            return 'Arial, Helvetica, sans-serif'; 
            break;

        case 'Comic Sans MS, cursive, sans-serif':
            return 'Comic Sans MS, cursive, sans-serif';
            break;

        case 'Impact, Charcoal, sans-serif':
            return 'Impact, Charcoal, sans-serif';
            break;

        case 'Lucida Sans Unicode, Lucida Grande, sans-serif':
            return 'Lucida Sans Unicode, Lucida Grande, sans-serif';
            break;

        case 'Tahoma, Geneva, sans-serif':
            return 'Tahoma, Geneva, sans-serif';
            break;

        case 'Verdana, Geneva, sans-serif':
            return 'Verdana, Geneva, sans-serif';
            break;

        default:
            return '';
            break;        
    }
}
?>

CSS

 body{
     font-family: <?php echo font_switch(get_option('fm_font_family')); ?>;
    }
    p{
     font-family: <?php echo font_switch(get_option('fm_font_family_text')); ?>;
    }

So in above function I want to pass option using get_option(‘my option id’) and want to use it for css as I am using same font family

If you have any other better option I can go for it too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T20:47:31+00:00Added an answer on June 11, 2026 at 8:47 pm

    I would rewrite to this, since you’re almost always returning the same value:

    <?php
    function font_switch($option)
    {
        switch($option){
            case 'Choose font family':
                return null;
    
            case 'Georgia, serif':
            case 'Palatino Linotype, Book Antiqua, Palatino, serif':
            case 'Times New Roman, Times, serif':
            case 'Arial, Helvetica, sans-serif':  
            case 'Comic Sans MS, cursive, sans-serif':
            case 'Impact, Charcoal, sans-serif':
            case 'Lucida Sans Unicode, Lucida Grande, sans-serif':
            case 'Tahoma, Geneva, sans-serif':
            case 'Verdana, Geneva, sans-serif':
                return $option;
    
            default:
                return '';
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wan to learn 1). How to call assembly code so that I can
I wan to insert this line of code: xml:lang=<?php echo $this->language; ?> lang=<?php echo
I want to convert function object to function. I wrote this code, but it
I wan't to divide my CI into multiple applications. I should say that it
I wan't to register the OnMouseOver and OnMouseOut-Event for an Image from the Code
I wan't to write a script to get the source of a website which
i want to add select query result into dataset, so i can write new
Does anyone now where i can find some good tutorials / code samples regarding
I'm using restler to write a REST api, and since I wan't to do
Hi I wan to create a contact, so here is my code: Intent addPersonIntent

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.