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
array_filter
ARRAY_FILTER(3) 1 ARRAY_FILTER(3)array_filter - Filters elements of an array using a callback functionSYNOPSIS
array array_filter (array $array, [callable $callback], [int $flag])
DESCRIPTION
Iterates over each value in the $array passing them to the $callback function. If the $callback function returns true, the current value
from $array is returned into the result array. Array keys are preserved.
PARAMETERS
o $array
- The array to iterate over
o $callback
- The callback function to use If no $callback is supplied, all entries of $array equal to FALSE (see converting to boolean) will
be removed.
o $flag
- Flag determining what arguments are sent to $callback:
o ARRAY_FILTER_USE_KEY - pass key as the only argument to $callback instead of the value
o ARRAY_FILTER_USE_BOTH - pass both value and key as arguments to $callback instead of the value
RETURN VALUES
Returns the filtered array.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.6.0 | |
| | |
| | Added optional $flag parameter and constants |
| | ARRAY_FILTER_USE_KEY and ARRAY_FILTER_USE_BOTH |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
array_filter(3) example
<?php
function odd($var)
{
// returns whether the input integer is odd
return($var & 1);
}
function even($var)
{
// returns whether the input integer is even
return(!($var & 1));
}
$array1 = array("a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);
$array2 = array(6, 7, 8, 9, 10, 11, 12);
echo "Odd :
";
print_r(array_filter($array1, "odd"));
echo "Even:
";
print_r(array_filter($array2, "even"));
?>
The above example will output:
Odd :
Array
(
[a] => 1
[c] => 3
[e] => 5
)
Even:
Array
(
[0] => 6
[2] => 8
[4] => 10
[6] => 12
)
Example #2
array_filter(3) without $callback
<?php
$entry = array(
0 => 'foo',
1 => false,
2 => -1,
3 => null,
4 => ''
);
print_r(array_filter($entry));
?>
The above example will output:
Array
(
[0] => foo
[2] => -1
)
Example #3
array_filter(3) with $flag
<?php
$arr = ['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4];
var_dump(array_filter($arr, function($k) {
return $k == 'b';
}, ARRAY_FILTER_USE_KEY));
var_dump(array_filter($arr, function($v, $k) {
return $k == 'b' || $v == 4;
}, ARRAY_FILTER_USE_BOTH));
?>
The above example will output:
array(1) {
["b"]=>
int(2)
}
array(2) {
["b"]=>
int(2)
["d"]=>
int(4)
}
NOTES
Caution
If the array is changed from the callback function (e.g. element added, deleted or unset) the behavior of this function is unde-
fined.
SEE ALSO array_map(3), array_reduce(3), array_walk(3).
PHP Documentation Group ARRAY_FILTER(3)