Hi,
I have two shell variables $t1 and $t2 which I need to pass to a function in a shell script. The function will do some computation with those two variables and echo the resultant. But I do not know how to pass teh arguments.
The function written is
f1()
{......
........
}
What should... (3 Replies)
In ksh shell,
There is a function f1.
function f1
{
How to read here??
....
....
}
I am passing values to fuunction f1 as
f1 "A" "B"
Please tell me how to read the passed values in function f1.
Advance Thanks & Regards
Prashant (2 Replies)
Hi,
I have an output generated from a shell script like;
0x41,0xF2,0x59,0xDD,0x86,0xD3,0xEF,0x61,0xF2
How can I pass this value to the C function, as below;
int main(int argc, char *argv) {
unsigned char hellopdu={above value};
}
Regards
Elthox (1 Reply)
Hi,
In the below C code , i want to pass the array to a unix shel script.
my script should called as ex myscript 1,2,3
#include <stdio.h>
int main()
{
int a={1,2,3};
}
Thanks,
Arun (1 Reply)
Hello,
Can anyone guide me tin passing parameters into user defined function of shell script (KSH).
Here is my code,
InsertRecord()
{
DB_TBL=$(sqlplus $USERID/$PASSWORD@$DATABASE << EOF
set head off
set feed off
set serveroutput on
INSERT INTO TBL1 ( OLD_VAL,
NEW_VAL,
... (7 Replies)
hi,
I have a array say
SAP_ARRAY="s1.txt"
SAP_ARRAY="s2.txt"
how can i pass this full array to a function.
here is the sample code i am using..
CHECK_NO_FILES()
{
FARRAY=$1
echo "FARRAY = $FARRAY"
echo "FARRAY = $FARRAY"
............... (5 Replies)
Hi All
I have multiple arrays like below.
set -A val1 1 2 4 5
set -A val2 a b c d
.
.
.
Now i would like to pass the individual arrays one by one to a function and display/ do some action.
Note : I am using ksh
Can you please advise any solution...
Thanks in advance. (7 Replies)
Dear Friends,
Please help me on this
my script name is send.csh
In this i have written the statement like this
set args = ( city state country price )
I want to pass this array to another c shell called receiver.csh. and i want to use it in this c shell
or
how to pass to... (2 Replies)
I want to make a config file which contain all the paths.
i want to read the config file line by line and pass as an argument on my below function.
Replace all the path with reading config path line by line and pass in respective functions.
how can i achieve that?
Kindly guide.
... (6 Replies)
Discussion started by: sadique.manzar
6 Replies
LEARN ABOUT PHP
each
EACH(3) 1 EACH(3)each - Return the current key and value pair from an array and advance the array cursorSYNOPSIS
array each (array &$array)
DESCRIPTION
Return the current key and value pair from an array and advance the array cursor.
After each(3) has executed, the array cursor will be left on the next element of the array, or past the last element if it hits the end of
the array. You have to use reset(3) if you want to traverse the array again using each.
PARAMETERS
o $array
- The input array.
RETURN VALUES
Returns the current key and value pair from the array $array. This pair is returned in a four-element array, with the keys 0, 1, key, and
value. Elements 0 and key contain the key name of the array element, and 1 and value contain the data.
If the internal pointer for the array points past the end of the array contents, each(3) returns FALSE.
EXAMPLES
Example #1
each(3) examples
<?php
$foo = array("bob", "fred", "jussi", "jouni", "egon", "marliese");
$bar = each($foo);
print_r($bar);
?>
$bar now contains the following key/value pairs:
Array
(
[1] => bob
[value] => bob
[0] => 0
[key] => 0
)
<?php
$foo = array("Robert" => "Bob", "Seppo" => "Sepi");
$bar = each($foo);
print_r($bar);
?>
$bar now contains the following key/value pairs:
Array
(
[1] => Bob
[value] => Bob
[0] => Robert
[key] => Robert
)
each(3) is typically used in conjunction with list(3) to traverse an array, here's an example:
Example #2
Traversing an array with each(3)
<?php
$fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry');
reset($fruit);
while (list($key, $val) = each($fruit)) {
echo "$key => $val
";
}
?>
The above example will output:
a => apple
b => banana
c => cranberry
Caution
Because assigning an array to another variable resets the original array's pointer, our example above would cause an endless loop
had we assigned $fruit to another variable inside the loop.
Warning
each(3) will also accept objects, but may return unexpected results. It's therefore not recommended to iterate though object proper-
ties with each(3).
SEE ALSO key(3), list(3), current(3), reset(3), next(3), prev(3), foreach, Object Iteration.
PHP Documentation Group EACH(3)