Yes thank you so much that finally worked! A followup question is:
Can you assign the all of the elements of the array to just one parameter? In your example you assigned the array elements 1-3 to $3 $4 $5 respectively. However, the number of elements in this array will change, and so it would nice to just be able to assign them all to one parameter.
I want to pass an array in my function, And my function will be changing the elements of the array in the fuction, but it should not affect the values in my array variable of main function (1 Reply)
Hi all..
Does anyone know have an example of passing the contents of a ksharray to oracle?
basically I am looking to loop through the contents of a file and store each line into a bash ksh. Once i have this I can then pass the array into an oracle procedure that accepts an array as an... (1 Reply)
Please excuse my ineptitude for a bit as I've been spoiled for the past few months with only writing perl code instead of C.
So ok, I've been thinking about some code to change the crc32 values that are held within central directory headers of zip files.
Because I'm lazy I decided to just... (3 Replies)
Hi experts,
I am here again with another Issue.
I need to pass the array as parameter / argument to another script.
I tried it as follows . ( I got this idea from the link )
$ cat test1.sh
#! /usr/bin/ksh
set -a arr1
echo "...In Test1...."
arr1="APPS_DEV"
arr1="TEST_DEV"
echo... (16 Replies)
Hi,
Please guide to pass an array as a arg to a script...
for example,
I have a script small.sh to find the small no of given arg as below...
#! /bin/sh
# this script is for finding the small number
set -A arr_no_updates
small=$1
i=1
for arr in $@
do
if (3 Replies)
Hi all,
Hereby wish to have your advise for below:
Main concept is
I intend to get current directory of my script file.
This script file will be copied to /etc/init.d.
A string in this copy will be replaced with current directory value.
Below is original script file:
... (6 Replies)
Hi, all
suppose I have following myfile (delimited by tab)
aa bb
cc dd
ee ffand I have following awk command:
awk 'BEGIN{FS="\t"}{AwkArrayVar_1=$1;AwkArrayVar_2=$2};END{for(i=0; i<NR; i++) print i, AwkArrayVar_1, AwkArrayVar_2,}' myfileMy question is: how can I assign the awk array... (7 Replies)
How do i pass an array from test4.sh to a function in another shell script test5.sh, basically i am sourcing the test5.sh in test4.sh and printing the contents, but not working below are my trial scripts, please help, thank you.
#!/bin/bash
# /usr/local/dw/archive/test5.sh
print_array()
{... (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)
Hi,
I am creating filesystem for block device, but I want to pass array value one by one acording to block device count.
$tmp1 = block device count 3
$blockdevice =
So I want to first pass sdb1 alone in loop, how to take only block device seprately from $blockdevice array. (1 Reply)
Discussion started by: stew
1 Replies
LEARN ABOUT PHP
array_splice
ARRAY_SPLICE(3) 1 ARRAY_SPLICE(3)array_splice - Remove a portion of the array and replace it with something elseSYNOPSIS
array array_splice (array &$input, int $offset, [int $length], [mixed $replacement = array()])
DESCRIPTION
Removes the elements designated by $offset and $length from the $input array, and replaces them with the elements of the $replacement
array, if supplied.
Note that numeric keys in $input are not preserved.
Note
If $replacement is not an array, it will be typecast to one (i.e. (array) $parameter). This may result in unexpected behavior when
using an object or NULL$replacement.
PARAMETERS
o $input
- The input array.
o $offset
- If $offset is positive then the start of removed portion is at that offset from the beginning of the $input array. If $offset is
negative then it starts that far from the end of the $input array.
o $length
- If $length is omitted, removes everything from $offset to the end of the array. If $length is specified and is positive, then
that many elements will be removed. If $length is specified and is negative then the end of the removed portion will be that many
elements from the end of the array. If $length is specified and is zero, no elements will be removed. Tip: to remove everything
from $offset to the end of the array when $replacement is also specified, use count($input) for $length.
o $replacement
- If $replacement array is specified, then the removed elements are replaced with elements from this array. If $offset and
$length are such that nothing is removed, then the elements from the $replacement array are inserted in the place specified by the
$offset. Note that keys in replacement array are not preserved. If $replacement is just one element it is not necessary to put
array() around it, unless the element is an array itself, an object or NULL.
RETURN VALUES
Returns the array consisting of the extracted elements.
EXAMPLES
Example #1
array_splice(3) examples
<?php
$input = array("red", "green", "blue", "yellow");
array_splice($input, 2);
// $input is now array("red", "green")
$input = array("red", "green", "blue", "yellow");
array_splice($input, 1, -1);
// $input is now array("red", "yellow")
$input = array("red", "green", "blue", "yellow");
array_splice($input, 1, count($input), "orange");
// $input is now array("red", "orange")
$input = array("red", "green", "blue", "yellow");
array_splice($input, -1, 1, array("black", "maroon"));
// $input is now array("red", "green",
// "blue", "black", "maroon")
$input = array("red", "green", "blue", "yellow");
array_splice($input, 3, 0, "purple");
// $input is now array("red", "green",
// "blue", "purple", "yellow");
?>
Example #2
array_splice(3) examples
The following statements change the values of $input the same way:
<?php
array_push($input, $x, $y);
array_splice($input, count($input), 0, array($x, $y));
array_pop($input);
array_splice($input, -1);
array_shift($input);
array_splice($input, 0, 1);
array_unshift($input, $x, $y);
array_splice($input, 0, 0, array($x, $y));
$input[$x] = $y; // for arrays where key equals offset
array_splice($input, $x, 1, $y);
?>
SEE ALSO array_slice(3), unset(3), array_merge(3).
PHP Documentation Group ARRAY_SPLICE(3)