473,383 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Need Help in arrays.. Please

1
Dear friends,

I am alittle trap in this arrays stuff if you peeps could help me in this will be very greatfull..


here is the problem I am facing rite now..

$array = array (
'Total Stock' =>
array (
0 => '26',
1 => '14',
2 => '9',
3 => '22',
4 => '2',
5 => '13',
6 => '27',
7 => '19',
),
'Pending Stock' =>
array (
5 => '11',
6 => '6',
7 => '21',
10 => '24',
11 => '25',
12 => '23',
13 => '8',
),
);

foreach ($array as $inarray => $enteries){

print_r($enteries);

}


In this array there are 2 groups so when i get the data it comes out like this ..

Array ( [0] => 26 [1] => 14 [2] => 9 [3] => 22 [4] => 2 [5] => 13 [6] => 27 [7] => 19 ) Array ( [5] => 11 [6] => 6 [7] => 21 [10] => 24 [11] => 25 [12] => 23 [13] => 8 )


But I want it to be like

Array ( [0] => 26 [1] => 14 [2] => 9 [3] => 22 [4] => 2 [5] => 13 [6] => 27 [7] => 19 [8] => 11 [9] => 6 [10] => 21 [11] => 24 [12] => 25 [13] => 23 [14] => 8 )


If there is a way please guide me..

Thanks,
Kucing Hunt
Dec 16 '06 #1
1 1076
ronverdonk
4,258 Expert 4TB
You must combine the two arrays into one array using the array_merge php command. This statement: [php]$result = array_merge($array['Total Stock'], $array['Pending Stock']);
echo '<pre>';
print_r($result);[/php] produces this result:
Expand|Select|Wrap|Line Numbers
  1. Array
  2. (
  3.     [0] => 26
  4.     [1] => 14
  5.     [2] => 9
  6.     [3] => 22
  7.     [4] => 2
  8.     [5] => 13
  9.     [6] => 27
  10.     [7] => 19
  11.     [8] => 11
  12.     [9] => 6
  13.     [10] => 21
  14.     [11] => 24
  15.     [12] => 25
  16.     [13] => 23
  17.     [14] => 8
  18. )
Ronald :cool:
Dec 17 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

41
by: Psykarrd | last post by:
I am trying to declare a string variable as an array of char's. the code looks like this. char name; then when i try to use the variable it dosn't work, however i am not sure you can use it...
21
by: Matteo Settenvini | last post by:
Ok, I'm quite a newbie, so this question may appear silly. I'm using g++ 3.3.x. I had been taught that an array isn't a lot different from a pointer (in fact you can use the pointer arithmetics to...
2
by: Pasacco | last post by:
dear I want to ask help on this problem. Array a is partitioned into a0 and a1 in main(). Then a1 is partitioned into a2 and a3 in th_partition() function. And I think this problem is something...
1
by: John Smith | last post by:
I have a two dimentional char array. Before filling it using strtok(), I reset its elements to '\0' using two nested for loops. The code works as I hope it would but I wonder whether I really need...
8
by: hothead098 | last post by:
ASSIGNMENT (4) USING AND MANIPUPATING ARRAYS (Chapter 10 material) For this assignment you are to: 1) Create and manage arrays a) One of type integers (containing 10 elements). b) One of...
3
by: alcabo | last post by:
Hello, I'd like to improve several critical routines involving arrays (vectors and matrices)... How are arrays stored in memory? Row major or column major? (Like in C or like Fortran?)
4
by: learnfpga | last post by:
Here is a little code I wrote to add the numbers input by the user.....I was wondering if its possible to have the same functionality without using dynamic arrays.....just curious..... ...
23
by: vinod.bhavnani | last post by:
Hello all, I need desperate help Here is the problem: My problem today is with multidimensional arrays. Lets say i have an array A this is a 4 dimensional static array.
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
1
by: ray2007colon | last post by:
I need to now how to compare the elements of two arrays. Here is my program. Now I need to compare each element. So I can print the arrays and the elements that are not the same. import...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.