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 7522157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:26:24+00:00 2026-05-30T02:26:24+00:00

Ok i just don’t have enough knowledge for this simple script apparently. Basically, in

  • 0

Ok i just don’t have enough knowledge for this simple script apparently. Basically, in the end I will be using an ifthen statement on the address field, if it’s empty, the map will not appear, if it’s got an address, the map will appear.

This is not the ifthen statement, i’m just trying to figure out how to write one from the array, or whatever, I’m getting. This is what I can get to output from the address field.

<?php

global $userdata, $app_abbr, $gmap_active;

$custom_fields = get_post_custom();
$varaddress = $custom_fields[$app_abbr.'_street'];

echo strlen($varaddress); //
var_dump($varaddress); //
echo string($varaddress);
?>

This is what I’m getting from that:

When the address field is empty:

5array(1) { [0]=> string(0) "" } 

When the address field is full:

5array(1) { [0]=> string(24) "14 South Magnolia Avenue" } 

I’m trying to figure out how to write a simple ifthen statement against this but it keeps coming back as true no matter how I try … so i broke it down to see exactly what was being returned and that was the output. How?

Ok since I now know how to “pop” something out of the array … lol here’s the ifthen statement that seems to work. Let me know if it can be streamlined or not:

<?php

global $userdata, $app_abbr, $gmap_active;

$custom_fields = get_post_custom();
$varaddress = $custom_fields[$app_abbr.'_street'];
$varmap = array_pop($varaddress);

if (strlen($varmap) >= 1 && !is_bool($varmap)) {
include_once ( TEMPLATEPATH . '/includes/sidebar-gmap.php' ); 
} else {
echo "NO ADDRESS GIVEN FOR MAP"; 
}

?>
  • 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-30T02:26:25+00:00Added an answer on May 30, 2026 at 2:26 am

    What you have is a one-element array. You can either access the address by its array index [0] or pop it off:

    echo $varaddress[0];
    // Or    
    echo array_pop($varaddress);
    

    The reason it gives you 5 for strlen() is that when you cast an array as a string as when passing it to a function like strlen(), it returns the string Array, which has a length of 5. The result is misleading and has nothing do do with the array’s actual contents.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe I just don't know .NET well enough yet, but I have yet to
This is probably quite simple, but I just don't know how to do this...
I just don't know how to solve this altough it's probably fairly simple. I
Okay this is a homework question, and I just don't have a clue how
I'm sure this is simple but I just don't know how to do it...
I have a simple problem but I just don't understand any of the examples
I have been battling with this code for quite a while and just don't
I just don't know how to explain this clearly. So I create a simple
Have tried all the examples on this website I just don't see anything on
I have a question that I just don't feel like I've found a satisfactory

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.