www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Easy string/variable operators

  1. #1
    Join Date
    Sep 2008
    Posts
    61

    resolved [RESOLVED] Easy string/variable operators

    Hey!

    Is there any way in php, to easily write this script shorter?

    Code:
    if(isset($row["name"])) {
    $row_name = "-";
    } else {
    $row_name = $row['name'];
    }
    
    echo "the name is $row_name;
    I am thinking possibly something like this:
    Code:
    echo "the name is " . ?isset($row['name']) row['name'] | "-";
    So..

    Always echo "the name is ", but ? (if) isset($row['name']) then echo row['name'] | (ELSE) echo "-";

    Any ideas?

    Cheers,
    Artheus

    ... A little newbie question ...

  2. #2
    Join Date
    Oct 2006
    Posts
    52
    Try:
    PHP Code:
    echo "the name is " . isset($row['name']) ? row['name'] : "-"

  3. #3
    Join Date
    Sep 2008
    Posts
    61
    Thanks a lot!
    It works perfectly!
    And didn't need to wait more than 10 minutes!

    Thanks again!

    Cheers,
    Artheus

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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



Recent Articles