Welcome to Discuss Everything Forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.


 

Tags for this Thread

+ Reply to Thread
Results 1 to 2 of 2
  1. #1

    PHP, do not display variable if false.?

    I have two variables.

    $type = 'Search Engine';
    $title = 'Yahoo' . $type;
    Output, Yahoo Search Engine

    What I'd like to do is to set $type = 0;
    and then verify $type in $title = 'Yahoo' . $type to see if $type is true or false.

    0=false.. If it's false, I want title to be.

    $title = 'Yahoo' . $other;

    Thanks in advance.

  2. #2
    Mark's Avatar
    Senior Member

    Status
    Offline
    Join Date
    May 2009
    Posts
    2,409
    Downloads
    0
    Uploads
    0
    I'm not sure exactly what you're trying to accomplish so I don't know if this will answer your question or not, but from what I got you should use arrays.

    // Set the info
    $info = array('type' => 'Search Engine', 'title' => 'Yahoo');
    // See if type exists, if not then set it to $other
    if (!$info['type']) $info['type'] = $other;
    // Implode the array into a single string
    //seperating type and title by a space
    $title = implode(' ', $info);

 

 

Quick Reply Quick Reply

Click here to log in


What is the number after 87?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to Display a PHP Variable in HTML in an Echo?
    By Micro Sniff in forum Discuss HTML
    Replies: 0
    Last Post: 11-29-2010, 05:34 AM
  2. Replies: 0
    Last Post: 09-30-2009, 03:36 AM
  3. How do I display a variable as image in php?
    By Asfandyar in forum Discuss PHP
    Replies: 0
    Last Post: 06-04-2009, 03:44 PM
  4. Replies: 0
    Last Post: 03-09-2009, 11:54 AM
  5. Replies: 1
    Last Post: 01-09-2009, 04:20 PM

Bookmarks

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •