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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:13:59+00:00 2026-05-29T07:13:59+00:00

I’m still having problems with arrays, I don’t know why … I’m getting response

  • 0

I’m still having problems with arrays, I don’t know why …
I’m getting response from web services with a number of room (0,1,2,3,4,5,…) and a renting value associated.
I will then need to do some calculation (average) per number of room.

So I thought that an array would be best.

But I’m struggling to create the array or arrays and populate it/them …

Thanks in advance.

The code is:

    // if the search is buy then search for rent as well to have an estimate value
    if ($_POST['ListingType'] == 'buy'){
        // Initialise the array
        $estimate = array();
        $estimate['requestCountry']    = 'UK';
        $estimate['requestEncoding']   = 'json';
        $estimate['searchPlaceName']   = $_POST['Location'];
        $estimate['filterListingType'] = 'rent';
        if(isset($_POST['PropertyType'])) 
            $estimate['filterPropertyType'] = $_POST['PropertyType'];
        else
            $estimate['filterPropertyType'] = 'all';
        if(isset($_POST['PriceMax']))
            $estimate['filterPriceMax']    = $_POST['PriceMax'];
        else
            $estimate['filterPriceMax']    = 'max';
        if(isset($_POST['PriceMin']))
            $estimate['filterPriceMin']    = $_POST['PriceMin'];
        else
            $estimate['filterPriceMin']    = 'min';
        if(isset($_POST['roomMax']))    
            $estimate['filterBedroomMax'] = $_POST['roomMax'];
        else
            $estimate['filterBedroomMax'] = 'max';
        if(isset($_POST['roomMin']))    
            $estimate['filterBedroomMin'] = $_POST['roomMin'];
        else
            $estimate['filterBedroomMin'] = 'min';
        $nestoriaEstimate = new Nestoria_Nestoria($estimate);
        //print_r( $nestoriaEstimate->decodedData);
        if (!empty($nestoriaEstimate->decodedData->response)) {
            $idxEst=0;
            $rentEst = array();
            foreach($nestoriaEstimate->decodedData->response->listings as $listingEst) {                
                switch ($listingEst->bedroom_number) {
                    echo '<div>Rent' . $listingEst->price_formatted . '<br/>Bedroom(s)' . $listingEst->bedroom_number . '</div>';
                }


            }
        }
    }

Which will display:

Rent450 GBP per month
Bedroom(s)1
Rent295 GBP per month
Bedroom(s)1
Rent545 GBP per month
Bedroom(s)2
Rent650 GBP per month
Bedroom(s)2
Rent395 GBP per month
Bedroom(s)1
Rent425 GBP per month
Bedroom(s)1
Rent500 GBP per month
Bedroom(s)1
Rent995 GBP per month
Bedroom(s)2
Rent395 GBP per month
Bedroom(s)1
Rent535 GBP per month
Bedroom(s)1
Rent695 GBP per month
Bedroom(s)2
Rent450 GBP per month
Bedroom(s)2
Rent475 GBP per month
Bedroom(s)2
Rent375 GBP per month
Bedroom(s)1

  • 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-29T07:14:00+00:00Added an answer on May 29, 2026 at 7:14 am

    Single dimensional arrays basically work as follows:

    You have a key/value pair for each “entry” in the array.

    an example would be:

     0 - Dog
     1 - Cat
     2 - Mouse
    

    Notice that by default the first index (key) is 0.

    You can obtain the value associated with the key by inserting the key into the brackets for the array variable.

    ex:

    echo $myArray[1];
    // this would yield Cat
    

    there is also an array type called an associative array in which case the indices are not numeric, but rather have textual representation (string).

    an example would be:

     pet - dog
     job - programmer
     hobby - kite flying
    

    so to pull a value out of an array like this, you would just use the textual representation in the brackets

    ex:

    echo $myArray["pet"];
    // would yield dog
    

    for your purposes, since the service is returning a 0 based list, you should use numeric indices as I showed above. to add new key/value pairs to your array, you can loop over the result set and do something like this:

    $myArray[] = $myValue;
    

    where each iteration of the loop will add the new key/value pair (just incrementing the keys from 0).

    EDIT (per your comment):

    to loop over an array you can use a for loop or a foreach loop.

    foreach example:

    $studio = Array(200,250,240,150);
    foreach($studio as $key => $val)
        echo $studio[$key]."<br />";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am currently running into a problem where an element is coming back from
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.