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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:20:39+00:00 2026-06-13T05:20:39+00:00

Ok, long story short: I am trying to place items in an array sorted

  • 0

Ok, long story short: I am trying to place items in an array sorted by a value as part of an object(the object defined as $aProductOrdered and the public value:productMan). The post will be variable depending on items added and removed from a database so it has to be dynamic.

For example if the index is 12 for a certain productMan value all items with that would be in one row like:

[12][0]:prodObj [12][1]:prodObj
[15][0]:prodObj 
[22][0]:prodObj [22][1]:prodObj

where the first is the prodMan value from the object and the second is an arbitrary auto assigned index to loop through representing each object.

Below is what I have but when I go to insert into the array, it accurately says the index I am trying to add to is undefined. How may I add the index if it doesn’t exist or if it does just append to it?

$vendOrderArray = array(array());

//here we will loop through all non blank posted orders and create objects to place them in our $orderArray
foreach($_POST as $prodID=>$numOrderded)
{
    if(is_numeric($numOrderded) && $numOrderded != "" && $numOrderded != "0")
    {
    $aProductOrdered = getProduct($prodId);
    $aProductOrdered->numberOrdered = $numOrderded;
    array_push($vendOrderArray[$aProductOrdered->productMan],$aProductOrdered);
    }
}
  • 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-13T05:20:40+00:00Added an answer on June 13, 2026 at 5:20 am
    if(!isset($vendOrderArray[$aProductOrdered->productMan]))
        $vendOrderArray[$aProductOrdered->productMan] = array();
    

    Just before the array_push call.

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

Sidebar

Related Questions

Long story short, I'm trying to add a few extra items to ViewData to
Long story short, I have an ASP.NET application I'm trying to debug and at
So long story short, im trying to build a chat application....well its already built
Long story short, I'm trying to write some toast-style popup notifications (similar to Growl)
Long story short I am trying to replicate the Sleeping barber problem in Erlang.
Long story short, I am trying to build a very bare bones UDP SKB
I'm trying to make a WCF service that will work with JSON-P (long-story short,
Okay, long story short I am having some trouble: I'm trying to send the
Long story short: I'm trying to write an app that'll dump IE's history to
Very long story short, I have a need to place a WinForms Panel and

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.