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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:40:46+00:00 2026-05-24T20:40:46+00:00

iam trying to build a multidimensional array. public function saveRateTemplateData($RateTemplateInfo) { $RateTemplateID = $RateTemplateInfo[‘id’];

  • 0

iam trying to build a multidimensional array.

public function saveRateTemplateData($RateTemplateInfo)
{
    $RateTemplateID = $RateTemplateInfo['id'];
    $Zones = $RateTemplateInfo['premium_zones'];
    //$ZoneZipCodeIDs[] = array();
    for ($n = 1; $n <= $RateTemplateInfo['premium_zones']; $n++) {
        $ZoneNum = 'zone' . $n;
        $ZipCodeArray = explode(",",$_POST[$ZoneNum]);
        $ZipCodeIDs=array();
        foreach ($ZipCodeArray as $v) {
            $v = intval(trim($v));
            if (strlen($v) == 5) {
                array_push($ZipCodeIDs, $this->addZipCode($v));  
            } else {
                echo "it isnt 5";
            }
        }
    }
}

so what iam trying to do is make an array of an array. so this is how its supposed to look

Array
(
  [1] => Array
    (
        [0] => 34
        [1] => 31
        [2] => 23
    )

  [2] => Array
    (
        [0] => 18
        [1] => 4
        [2] => 35
        [3] => 1
    )
)

i have tried numerous ways it doesnt work
basically i want it in this format VarName[ZoneNumbers][ZipCodeID]

so i can loop through it later on. so i can print like this $VarName[$n] then a array of all zipcodeID will print for Zone Number 1 in this case it will print 34,31,23

  • 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-24T20:40:48+00:00Added an answer on May 24, 2026 at 8:40 pm
    public function saveRateTemplateData($RateTemplateInfo)
    {
        $RateTemplateID = $RateTemplateInfo['id'];
        $zones = array(); // you weren't using this so I'll use it to hold the data
    
        for ($n = 1; $n <= $RateTemplateInfo['premium_zones']; $n++) {
            $ZoneNum = 'zone' . $n;
    
            // create an array under the zone number for holding the IDs
            $zones[$n] = array();
    
            $ZipCodeArray = explode(",",$_POST[$ZoneNum]);
            foreach ($ZipCodeArray as $v) {
                $v = (int) trim($v);
                if (strlen($v) == 5) {
                    $zones[$n][] = $this->addZipCode($v);
                } else {
                    // use exceptions for exceptional circumstances
                    throw new RuntimeException(sprintf('Invalid zone ID "%s"', $v));
                }
            }
        }
    
        return $zones;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to build a function in C/C++ to sort an array and
Iam trying to build an Facebook Application based on PHP. The Application is running
iam trying to build an multihreading webservice. Single threading is working, in my main
I am trying to build an website for my college's magazine. I used the
I am trying to build out a useful 3d game engine out of the
I am trying to build a dependency graph of tables based on the foreign
I am trying to build an Eclipse application that would work with a linux/motif
I am trying to build a dropdown list for a winform interop, and I
I am trying to build a homebrew web brower to get more proficient at
I am trying to build a CAML query for SharePoint 2007 environment, to get

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.