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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:26:19+00:00 2026-06-04T15:26:19+00:00

My returned array is coming back in this strange format that is not valid.

  • 0

My returned array is coming back in this strange format that is not valid. At least not in my AJAX experience.

function get_within($latitude, $longitude) { 
global $pdo;

  // $lat = $latitude;
  // $long = $longitude;
  // $long = '-70.98245279999999';
  // $lat = '41.98156549999999';

    $stmt = $pdo->prepare("SELECT menu_id, latitude, longitude ( acos(
          cos( radians(".$latitude."   ) ) *
            cos( radians( latitude) ) * 
            cos( radians(".$longitude.") - radians(longitude)) +
            sin( radians(".$latitude.") ) * sin( radians(latitude) ) ))*.621371192
as dis from pages where 1 ORDER BY `dis` ASC LIMIT 10");

$stmt->execute( array() );

return $stmt->fetchAll( PDO::FETCH_OBJ );

I made an AJAX request using the above function. I need it to return an object but it is only returning an array like this:

[{"id":"26","subject_id":"5","menu_name":"Bobby Byrne's Food & Pub\u200e","position":"1","visible":"1","content":"Bobby Byrne's Restaurant & Pub\u200e\r\n65 Massachusetts 6A, Sandwich, MA\r\n(508) 888-6088","longitude":"-70.508598","latitude":" 41.765754","dis":"0.00245126419033985"}]

What is wrong and how can I get back my query in objects correctly for use?

  • 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-06-04T15:26:21+00:00Added an answer on June 4, 2026 at 3:26 pm

    Your response is a JSON encoded object. You need to decode the JSON to an object.

    Please see:
    http://php.net/manual/en/ref.json.php

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

Sidebar

Related Questions

I have an array returned by the function Search.all : => [#<Search id: 7,
When I am accessing an Array of data that is returned from nusoap I
I'm trying to pass an array to json.stringify but the returned value is coming
I'm using Set class of Cakephp to format the find returned array but cannot
I want a function that creates an array of increasing floats. I run into
I have a code that fetches a list from DB. Using that returned array
I have a returned multi dimensional array from my DB, looking something like this
Ok, lets start with the code. I am looping through a returned array of
I want to store the array returned by a method into another array. How
I have one main array which is the returned data from a MySQL query

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.