473,395 Members | 1,999 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,395 software developers and data experts.

How to add columns to an existing array

Claus Mygind
571 512MB
I have an array with one column in each row. I want to expand the array so each row has 12 columns. How can I do that?

from
array(val1, val2, val3,...)

to
array(array1(val1,val2,val3...,val12), array2(val1,val2,val3...,val12),...)

I want to preserve the value in the first column as the first value in each row of the expanded array.

Is there a php function that will expand the array so I can then subsequently fill in the blank values?
Mar 11 '13 #1

✓ answered by Claus Mygind

Never mind it seem to be pretty simple
Expand|Select|Wrap|Line Numbers
  1.         for($i = 0, $size = count($aDupInvoice); $i < $size; ++$i) {
  2.  
  3.  
  4.             $thisLine =  $aDupInvoice[$i];
  5.             $aDupInvoice[$i] = 
  6.                 array(
  7.                     $aDupInvoice[$i],
  8.                     $oCGI['chk'.$thisLine],
  9.                     $oCGI['INVOICENUM'.$thisLine],
  10.                     $oCGI['RPTNUM'.$thisLine],
  11.                     $oCGI['DETAILCODE'.$thisLine],
  12.                     $oCGI['DATE'.$thisLine],
  13.                     $oCGI['QUANTITY'.$thisLine],
  14.                     $oCGI['RATE'.$thisLine],
  15.                     $oCGI['AMOUNT'.$thisLine],
  16.                     $oCGI['DESCRIPTION'.$thisLine],
  17.                     $oCGI['Engineer'],
  18.                     $oCGI['chk'.$thisLine].$oCGI['INVOICENUM'.$thisLine].$oCGI['RPTNUM'.$thisLine]
  19.  
  20.             );
  21.         }
  22.  

1 9349
Claus Mygind
571 512MB
Never mind it seem to be pretty simple
Expand|Select|Wrap|Line Numbers
  1.         for($i = 0, $size = count($aDupInvoice); $i < $size; ++$i) {
  2.  
  3.  
  4.             $thisLine =  $aDupInvoice[$i];
  5.             $aDupInvoice[$i] = 
  6.                 array(
  7.                     $aDupInvoice[$i],
  8.                     $oCGI['chk'.$thisLine],
  9.                     $oCGI['INVOICENUM'.$thisLine],
  10.                     $oCGI['RPTNUM'.$thisLine],
  11.                     $oCGI['DETAILCODE'.$thisLine],
  12.                     $oCGI['DATE'.$thisLine],
  13.                     $oCGI['QUANTITY'.$thisLine],
  14.                     $oCGI['RATE'.$thisLine],
  15.                     $oCGI['AMOUNT'.$thisLine],
  16.                     $oCGI['DESCRIPTION'.$thisLine],
  17.                     $oCGI['Engineer'],
  18.                     $oCGI['chk'.$thisLine].$oCGI['INVOICENUM'.$thisLine].$oCGI['RPTNUM'.$thisLine]
  19.  
  20.             );
  21.         }
  22.  
Mar 11 '13 #2

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

Similar topics

2
by: Dave | last post by:
Can I determine if an array of image links is already in memory without using cookies or a hidden frameset? Scenario: visitor starts with Home page, images (links) for navigation pre-load no...
5
by: mark4asp | last post by:
Suppose I wanted to create an array that was associative in 2 dimensions. The rows are associated with numbers. The columns with words. For instance for 3 columns. This array will have 20 rows...
35
by: VK | last post by:
Whatever you wanted to know about it but always were affraid to ask. <http://www.geocities.com/schools_ring/ArrayAndHash.html>
0
by: Arpan | last post by:
An ASP application needs to display DISTINCT records of all the columns existing in a SQL Server DB table in different drop-down lists. The column names & the no. of columns aren't known while...
1
by: moonriver | last post by:
I intend to generate a variable-length array, similar to link lists in plain C. For example, I define the following array int a Initially I assign 5 elements to the array as a = new int...
11
by: Zordiac | last post by:
How do I dynamically populate a string array? I hope there is something obvious that I'm missing here Option Strict On dim s() as string dim sTmp as string = "test" dim i as integer ...
10
by: | last post by:
I'm fairly new to ASP and must admit its proving a lot more unnecessarily complicated than the other languages I know. I feel this is because there aren't many good official resources out there to...
3
oll3i
by: oll3i | last post by:
how to add a new element to an existing array?
28
Nepomuk
by: Nepomuk | last post by:
Hi! I've read, that in C++ there's no predefined method, to calculate the size of an array. However, it's supposed to work withsizeof(array)/sizeof(array)Now, this does work in some situations, but...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.