LIMITITERATOR(3) 1 LIMITITERATOR(3)The LimitIterator classINTRODUCTION
The LimitIterator class allows iteration over a limited subset of items in an Iterator.
CLASS SYNOPSIS
LimitIterator
LimitIteratorextends
IteratorIteratorOuterIterator
Methods
o public LimitIterator::__construct (Iterator $iterator, [int $offset], [int $count = -1])
o public mixed LimitIterator::current (void )
o public Iterator LimitIterator::getInnerIterator (void )
o public int LimitIterator::getPosition (void )
o public mixed LimitIterator::key (void )
o public void LimitIterator::next (void )
o public void LimitIterator::rewind (void )
o public int LimitIterator::seek (int $position)
o public bool LimitIterator::valid (void )
EXAMPLES
Example #1
LimitIterator usage example
<?php
// Create an iterator to be limited
$fruits = new ArrayIterator(array(
'apple',
'banana',
'cherry',
'damson',
'elderberry'
));
// Loop over first three fruits only
foreach (new LimitIterator($fruits, 0, 3) as $fruit) {
var_dump($fruit);
}
echo "
";
// Loop from third fruit until the end
// Note: offset starts from zero for apple
foreach (new LimitIterator($fruits, 2) as $fruit) {
var_dump($fruit);
}
?>
The above example will output:
string(5) "apple"
string(6) "banana"
string(6) "cherry"
string(6) "cherry"
string(6) "damson"
string(10) "elderberry"
PHP Documentation Group LIMITITERATOR(3)
Check Out this Related Man Page
ARRAYITERATOR(3) 1 ARRAYITERATOR(3)The ArrayIterator classINTRODUCTION
This iterator allows to unset and modify values and keys while iterating over Arrays and Objects.
When you want to iterate over the same array multiple times you need to instantiate ArrayObject and let it create ArrayIterator instances
that refer to it either by using foreach or by calling its getIterator() method manually.
CLASS SYNOPSIS
ArrayIterator
ArrayIteratorArrayAccessSeekableIteratorCountableSerializable
Methods
o public void ArrayIterator::append (mixed $value)
o public void ArrayIterator::asort (void )
o public ArrayIterator::__construct ([mixed $array = array()], [int $flags])
o public int ArrayIterator::count (void )
o public mixed ArrayIterator::current (void )
o public array ArrayIterator::getArrayCopy (void )
o public void ArrayIterator::getFlags (void )
o public mixed ArrayIterator::key (void )
o public void ArrayIterator::ksort (void )
o public void ArrayIterator::natcasesort (void )
o public void ArrayIterator::natsort (void )
o public void ArrayIterator::next (void )
o public void ArrayIterator::offsetExists (string $index)
o public mixed ArrayIterator::offsetGet (string $index)
o public void ArrayIterator::offsetSet (string $index, string $newval)
o public void ArrayIterator::offsetUnset (string $index)
o public void ArrayIterator::rewind (void )
o public void ArrayIterator::seek (int $position)
o public string ArrayIterator::serialize (void )
o public void ArrayIterator::setFlags (string $flags)
o public void ArrayIterator::uasort (string $cmp_function)
o public void ArrayIterator::uksort (string $cmp_function)
o public string ArrayIterator::unserialize (string $serialized)
o public bool ArrayIterator::valid (void )
PHP Documentation Group ARRAYITERATOR(3)
Hi, I have a small question about the value cannot display correctly:
MSG=log
fruit=apple
print "No $fruit in the store" > "$MSG/fruit_message.txt"
output: No $fruit in the store
should be: No apple in the store
AND
$MSG/fruit_message.txt ----------> cannot find the... (5 Replies)
i have the following text file:
10: fruits
apple
mango
orange
20: vegetables
tomato
30: icecreams
vanilla
Pista
If is search for pista , it should return 30. or if i search for mango it should return 10.
Please let me know how it can be done efficiently in a shell... (3 Replies)
Hi there,
Is there any equivalent command in UNIX for gotoxy() function of C? I'm having difficulty placing the input of user from a specified line. Say I have below output:
I would want user to input their answer immediately after the question but still the choices of answer is displayed... (3 Replies)
I have a program that takes two responses, for example:
./eatfruit
<stdout>
Enter fruit:
Do you want to eat fruit?:
<end stdout>
If I do this
yes banana ./eatfruit
<stdout>
Enter fruit:
banana (2 Replies)
I have a big list as the following:
apple X:5_yes_a
apple X:12_no_b
apple X:45_yes_a
apple X:100_no_b
banana X:7_yes_a
banana X:13_yes_a
banana X:42_no_a
cat X:42_no_b
cat X:77_yes_d
I'd like to parse the file so that for each $1 value I return only lines in which the value in $2... (4 Replies)
Hi...
i need a script to remove the space before and after the operator like( +, -, ||, &&).
Ex :
Input file
apple + manago
mango && fresh + apple fresh || fruit
Desired output:
apple+manago
mango&&fresh+apple fresh||fruit (6 Replies)
Hi...
i need a script to remove the space before and after the operator like( / ).
Ex :
Input file
apple / manago
mango / fresh apple / fresh
Desired output:
apple/manago
mango/fresh apple/fresh
Note: betwee the desired operator space should be removed, between words do not remove... (3 Replies)
Hi
I have a pipe delimited file. I am trying to grab the DISTINCT value from the second field. The file is something like:
1233|apple|ron
1234|apple|elephant
1235|egg|man
the output I am trying to get from second field is apple,egg (apple coming only once)
Thanks
simi (4 Replies)
Hi experts,
I need urget help! I have the a text file with this format:
Types of fruits
Name of fruits
1,1
Farm_no,1
apple,1
pineapple,1
grapes,1
orange,1
banana,1
2,2--->this is the record seperator
Farm_no,2
apple,1
pineapple,1
grapes,3
orange,2
banana,1
3,3--->this is the... (2 Replies)
I am unable to resolve the below code compilation issue:
class A
{
public:
int x;
};
void sort_A(TArray<A> &_Atype)
{
std::stable_sort (_Atype.begin(), _Atype.end());
}
bool operator< (const A & _a1, const A & _a2)
{
return _a1.x < _a2.x;
}
When we compile using gcc 4.1.2... (4 Replies)
Hi, unix Gurus,
I want to split file based on sub_title. for example:
original file
fruit
apple
watermelon
meat
pork
fish
beef
expected result file
file1
fruit
apple
watermelon
file2
meat
pork
fish
beef. (4 Replies)
Need to search a pattern occurrence (count) in a specified file.
Below is the details
$ cat fruits
apple apple
ball ball
apple
ball ball ball
apple apple apple
cat cat
cat cat cat
apple
apple
Note: If I'll use the grep command with -c option then it'll count the 1st occurrence in... (6 Replies)
Hi,
I have 2 files as seen below.
File 1:
apple#fruit
carrot#vege
orange#fruitFile 2:
#list of fruits
fruitlist
:
apple#fruit
grape#fruit
orange#fruit
finish (3 Replies)
Hi guys.
I'm trying to do a search on the fruit & brand inside Fruit.txt, and printing the result out in the following format:
, , $,
I am able to do this via the following code:
awk -F: -vOFS=", " -vt="$Fruit:$Brand" '$0~t{$3="$"$3;print}' Fruit.txt
However, I want to be able to... (5 Replies)
hi
i have a file as in follwoing:
cat apple.txt
Apple is a fruit
But this fruit is costly
Now I used the sed command and i see output as in following
# sed 's/fruit/healthy &/' fruit.txt
Apple is a healthy fruit
But this healthy fruit is costly
#
sed works fine here. But... (2 Replies)