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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:43:55+00:00 2026-05-30T21:43:55+00:00

I have a Address_Finder class with a method get_address( $ordinal, $postcode ) that uses

  • 0

I have a Address_Finder class with a method get_address( $ordinal, $postcode ) that uses a mixture of google map API and a database to get a full address

get_address finds the address details: lat, lng, street_name, etc from a $ordinal and $postcode and once called, it sets the instance’s address variables to the results.

If it finds the address successfully, it sets the internal data to the results and returns true.

However if the address already exists in the database, it returns the address_id of the address in the database.

So obviously the return values for the function are either true, or a standard php integer type.

We could do something like this:

$address = new Address_Finder();
$address_id = $address -> get_address( "2", "NG8 5NW" );

if ( $address_id ){
    $address_id = $address -> save(); // saves the address to the database
}

Now the if ( $address_id ) will evaluate true if get_address returns true, or if it returns the $address_id 1.

This could be solved by doing:

if ( $address_id === true ){
    // save returns the address ID of the last inserted address
    $address_id = $address -> save();
}

However I was wondering if there way a better way to do this?

Like… I was hoping to release my Address_Finder class as an API on my blog so other programmers out there can use it.

So by ‘better way’, I’m thinking in terms of how programmers will use my API

  • 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-30T21:43:56+00:00Added an answer on May 30, 2026 at 9:43 pm

    Return an array instead of a simple value:

    {
     'success':true||false,  //boolean indicating if get_address was successfull
     'id':     int||null     //id returned by get_address when successfull
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an address class that uses a regular expression to parse the house
I have a database with Points of Interest that all have an address. I
I have an address object that I want to create an equals method for.
I have an Address class in C# that looks like this: public class Address
I have an address column that contains address, state and postcode. I would like
I have an address finder system whereby a user enters a postcode, if postcode
I have an address database and I tried to find latitude and longitude using
Problem: I have an address field from an Access database which has been converted
I have two classes Address and Employee as follows: public class Address { public
I have this webserver that have an IP address xxx.xxx.xx.x, I also have a

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.