Greetings.
I'm having a time of it with this file. I'm trying to do a script that will take two command line inputs, string1 and string2 and use sed to change the text over files in the current directory. This is what I have so far. It appears to work a little, it does create the... (3 Replies)
Hi,
I have a directory call Test, which contains files "a", b", "c", etc. I want to go through all of the files inside Test and remove any empty file. How would I do that with shell csh?
So far I got...
#!/bin/csh
if (($#argv == 0) || ($#argv > 1)) then
echo "no argument or too... (2 Replies)
Hi
i need to find x in the following equation such that it satisfies this condition:
y/x-ln(x)-1.24=0
how can i write a script to iterate to give random x to satisfy this equation.
y is different each time too. any help with awk/shell script will be awesome!
thanks (1 Reply)
I'm trying to send the file list as parameter to another job and execute it.
But the loop doesn't work, the inner job is running only once and not twice as expected
for filelist in $(ls -rt *.txt | tail -2)
do
echo $filelist
export filelist
cmd="$Program -config $configfile -autoexec... (11 Replies)
I'm trying to grab a list of file names from a directory, then process those files 5 at a time. In the link below. Instead of using files I'm using the files array which contains 15 strings starting with AAA.
So I'm trying to assign $fileset 5 of the strings at a time to pass to a command. So... (4 Replies)
I can not figure out how to iterate a perl command that inputs a value into columns and then combines them. I need to put a numerical value in column one and the word "Null" in all others, and then join at the end. I think the below is close, but I am not sure about the lines in bold. I... (7 Replies)
Have two 3 files which has list of servers,users and location and base url which is common on every server
A = server1 server2 server3
B = user1 user2 user3
C = dom1 dom2 dom3
baseurl=/opt/SP/
and what i have to achieve is below via ssh from REMOTE SERVER
for it's first iteration it... (7 Replies)
I would like to iterate over `dirs`in a script, but the script will never show more than one (current) folder
#! /bin/bash
for i in `dirs`
do
echo ${i}
done
echo ++++++++++++++++++
for i in $( dirs -p )
do
echo ${i}
done
echo ------------------
dirscontent=`dirs`
echo... (5 Replies)
Discussion started by: alexanderb
5 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)