Corona688 was great in helping me learn how to create arrays that hold other two dimensional array here. Unfortunately I didn't think ask about how to implement or call them. Basically, I'm trying to call an array of two-dimensional arrays like this:
declaration:
call:
gcc warnings:
I've tried changing the argument in this function, how I call the function, and a lot of things, but no luck. Here is the function the function call goes to:
I'm sure the loops in the function are wrong. Sure it can probably be done in less than 3 loops. I won't be mad to get suggestions on those, but right now I'm just trying to pass the argument correctly.
Any advice much appreciated.
Last edited by Don Cragun; 09-09-2018 at 03:42 AM..
Reason: Fix CODE tags.
Hi,
I am trying to assign an array as a value to one of the array element, I mean
I have an array @KS and array @kr.
I want array @KS to hold @kr as an element.
So I am doin this
$KS=@kr;
But the value stored is number of elements in the @kr array.
Can... (2 Replies)
Suppose there are two arrays of arrays:
@A = ( , , , );
@B = ( , , , , );
For each of $A, $A, $A..., I want to find the corresponding one in @B (match the letter, like $A eq $B), and print out both the second item, for example, $A and $B.
How can I do this in perl? grep + map? Hope I... (1 Reply)
PHP question...I posted this on the Web Development forum, but maybe this is a better place!
I have an SQL query that's pulled back user IDs as a set of columns. Rather than IDs, I want to use their names.
So I have an array of columns $col with values 1,7,3,12 etc and I've got an array $person... (3 Replies)
Hi All
I need to get <STDIN> from a user. the <STDIN> is a range of number delimited by "," (comma) and can be with range delimited by "-".
Example: 1,2,3,4-9,12,15,34-36,70
Now I need to get this from the user and go on each number and "Do something"... but when trying to do this as above... (2 Replies)
here is what i have...
i=1
while read line
do
if grep -i-q "create procedure"<<<$line
then
startline="$line"
endline="blahblah"
Get procedure name into a variable named procName
procName="procedure name is stored"
do some... (2 Replies)
hello,
i need a bit of help on how to do this effectively in bash without a lot of extra looping or massive switch/case
i have a long array of M elements and a short array of N elements, so M > N always. M is not a multiple of N.
for case 1, I want to stretch N to fit M
arrayHuge
H = (... (2 Replies)
I hate I'm asking for help again. Unfortunately it seems there just aren't any links I can find on making an array that holds a bunch of two dimensional arrays. Maybe my google-fu is lacking. Basically I have a header file like this:
#define MATRIX 10
int white_l1;
int white_l2;
int... (2 Replies)
Le sigh... Hopefully this will be the last time I have to ask for help on this topic. For a while now I've been working with a 1d array that holds 2d arrays. For reference you can view here. Now I'm just trying to loop through the elements with the following:
#include <stdio.h>
void... (3 Replies)
So I need to Write an array processing program using a Linux shell programming language to perform the following.
Load array X of 20 numbers from an input file X.
Load array Y of 20 numbers from an input file Y.
Compute array Z by multiply Xi * Yi then compute the square-root of this... (2 Replies)
Discussion started by: sarapham409
2 Replies
LEARN ABOUT PHP
array
ARRAY(3) 1 ARRAY(3)array - Create an arraySYNOPSIS
array array ([mixed $...])
DESCRIPTION
Creates an array. Read the section on the array type for more information on what an array is.
PARAMETERS
o $...
- Syntax "index => values", separated by commas, define index and values. index may be of type string or integer. When index is
omitted, an integer index is automatically generated, starting at 0. If index is an integer, next generated index will be the big-
gest integer index + 1. Note that when two identical index are defined, the last overwrite the first. Having a trailing comma
after the last defined array entry, while unusual, is a valid syntax.
RETURN VALUES
Returns an array of the parameters. The parameters can be given an index with the => operator. Read the section on the array type for more
information on what an array is.
EXAMPLES
The following example demonstrates how to create a two-dimensional array, how to specify keys for associative arrays, and how to skip-and-
continue numeric indices in normal arrays.
Example #1
array(3) example
<?php
$fruits = array (
"fruits" => array("a" => "orange", "b" => "banana", "c" => "apple"),
"numbers" => array(1, 2, 3, 4, 5, 6),
"holes" => array("first", 5 => "second", "third")
);
?>
Example #2
Automatic index with array(3)
<?php
$array = array(1, 1, 1, 1, 1, 8 => 1, 4 => 1, 19, 3 => 13);
print_r($array);
?>
The above example will output:
Array
(
[0] => 1
[1] => 1
[2] => 1
[3] => 13
[4] => 1
[8] => 1
[9] => 19
)
Note that index '3' is defined twice, and keep its final value of 13. Index 4 is defined after index 8, and next generated index (value
19) is 9, since biggest index was 8.
This example creates a 1-based array.
Example #3
1-based index with array(3)
<?php
$firstquarter = array(1 => 'January', 'February', 'March');
print_r($firstquarter);
?>
The above example will output:
Array
(
[1] => January
[2] => February
[3] => March
)
As in Perl, you can access a value from the array inside double quotes. However, with PHP you'll need to enclose your array between curly
braces.
Example #4
Accessing an array inside double quotes
<?php
$foo = array('bar' => 'baz');
echo "Hello {$foo['bar']}!"; // Hello baz!
?>
NOTES
Note
array(3) is a language construct used to represent literal arrays, and not a regular function.
SEE ALSO array_pad(3), list(3), count(3), range(3), foreach, The array type.
PHP Documentation Group ARRAY(3)