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

  • SEARCH
  • Home
  • 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 6955519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:44:49+00:00 2026-05-27T14:44:49+00:00

Here is a bit of code that displays: ‘varname: varvalue’ in a browser. It

  • 0

Here is a bit of code that displays: ‘varname: varvalue’ in a browser. It is used by calling the vc(‘varname’); or vc(array(‘multiple’,’varnames’));

I first tried writing:

if (gettype($$var_string) == ('string' || 'boolean' || 'integer' || 'double')){}

however this didn’t work. The second group simplifies to true, and it always passed the conditional check.

So, I wrote out each check separately. I’m new to coding, I’m sure there’s an easier way, not sure what it would be. I haven’t had any luck searching here or google. (probably not using the right jargon). Thanks in advance. – Mike

Oh, this is PHP, btw. The problem in question applies to any language thou.

define('LB', '<br />');
$var1 = 5;
$var2 = array('mike', 'lewis', 'is', 'awesome');

function vc($var_string) {
    if (!is_array($var_string)){
    $var_string = array($var_string);
    }
foreach ($var_string as $var_string){
    global $$var_string;
    if (    (gettype($$var_string) == 'string') || 
            (gettype($$var_string) == 'boolean') || 
            (gettype($$var_string) == 'integer') || 
            (gettype($$var_string) == 'double') ) {
        print('<strong>'. $var_string . ': </strong>' . $$var_string . LB);        
    } elseif (  (gettype($$var_string) == 'array') || 
                (gettype($$var_string) == 'object') || 
                (gettype($$var_string) == 'resource')){
        print('<strong>' . $var_string . ': </strong>');
        print_r($$var_string);
        print(LB);
    }
} 
}

vc('var1');
vc('var2');
vc(array('var1', 'var2'));
  • 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-05-27T14:44:49+00:00Added an answer on May 27, 2026 at 2:44 pm

    You can do something like this:

    if( in_array($variable_to_test, Array("option1", "option2", "option3"))) {
        // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little bit of Javascript that almost works correctly. Here's the code:
I have a bit of code that basically displays the last x (variable, but
I'm trying to do an Outer Join in Symfony. Here's the bit of code
It seems like I had to inline quite a bit of code here. I'm
Here's the relevant bit of the source code: class Dice { String name ;
First, to make my job explaining a bit easier, here's some of my code:
I'm a bit confused here. Microsoft as far as I can tell claims that
I see the terms managed and unmanaged used a fair bit around here. Searching
Here's a simple MVC View that displays all Areas in a DB and then
EDIT: As Oren Bengigi suggested, I tried enclosing the bit of code that saves

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.