Skip to main content
1 vote
1 answer
470 views

Proper type hinting for IteratorAggregate satisfying Psalm and PhpStorm

I have collections using IteratorAggregate interface. And I can't find a way how to type hint it properly that both Psalm and PhpStorm are satisfied. Here is a simplified example. It has an ...
nickel715's user avatar
  • 2,853
1 vote
1 answer
147 views

How To Store PHP Array In Javascript Array And Display?

I've tried using json_encode to store a PHP array as a javascript array, but when I try to display the javascript array or reference an index of it, it shows as empty or undefined. What I basically ...
Eric Egana's user avatar
2 votes
2 answers
792 views

Can't we iterate material-ui inside an array in React.js?

I have been trying to use material-ui and iterate over it inside an array ( for creating ratings for some items like in e-commerce sites). The code isn't working. On my localhost server, it's not ...
Saroj Pandeya's user avatar
5 votes
0 answers
169 views

PHP ArrayIterator and current()

I have this piece of PHP code: echo 'PHP ' . phpversion()."\n"; $arr = array(); for ($i=0; $i<10; $i++) { $arr[] = new stdClass(); } $it = new ArrayIterator($arr); $i = 1; foreach (...
andreas's user avatar
  • 149
0 votes
3 answers
63 views

how can I iterate through this array of hashes to receive a particular value : RUBY

the hash I have is the following: aoh=[ { "name": "Vesper", "glass": "martini", "category": "Before Dinner Cocktail", "ingredients": [ { "unit": "cl", "amount": 6, ...
st123's user avatar
  • 264
0 votes
1 answer
563 views

Removing part of an array from a multidimensional nested array

I've a four levels of nested array like this: $array = [ [ 'website' => [ 'id' => 'one' ], 'children' => [ [ 'website' =&...
Tuhin's user avatar
  • 195
1 vote
1 answer
80 views

Can I use an Array Iterator to do the same function as a for loop?

I'm trying to understand if it is possible to use an array iterator (like .forEach()) to complete the same functionality as a for loop. I am trying to understand javascript event listeners and have ...
Pete Smyth's user avatar
9 votes
1 answer
2k views

What does “Using non reentrant iterator method: Array.iterator()” error message mean?

This is my first project in libGDX and I am trying to loop a com.badlogic.gdx.utils.Array: //properties ... private Array<Item> items; ... //constructor ... items = new Array<Item>(); ....
Waqleh's user avatar
  • 10.2k
0 votes
4 answers
91 views

Is there a possible way to loop through arrays at a specific range rather than loop through the whole thing?

I'm currently going through array exercises to practice my programming on array iteration. I have an array of string objects inside that look like this. var balling = [ "Calvin Klein", "Tommy ...
Kenneth McAusland's user avatar
2 votes
2 answers
591 views

How to optimize an ArrayIterator implementation in PHP?

I have a long running PHP daemon with a collection class that extends ArrayIterator. This holds a set of custom Column objects, typically less than 1000. Running it through the xdebug profiler I found ...
Matt S's user avatar
  • 15.5k
1 vote
1 answer
547 views

Handlebars.js How to itarate through nested array using outer loop index

Hi. My JSON is: variants : [ { name : "one", segments : [ { value : 1 }, { value : 2 }, { value : 3 } ] }, { name : "two", segments : [ { value : 4 },...
Sergey  Dragushin's user avatar
2 votes
2 answers
126 views

php: Always losing item #1 in ArrayIterator with using ArrayIterator::offsetUnset for a current element in loop

I'm always losing second item (#1) in forearh of ArrayIterator and removing each element. $cnt = 0; $a = new ArrayIterator(); $a->append(++$cnt); $a->append(++$cnt); $a->append(++$cnt); $a-&...
Kirby's user avatar
  • 3,127
3 votes
1 answer
1k views

How do I append an element with a key using ArrayIterator in PHP?

There is no documentation on the PHP site for the ArrayIterator object beyond a basic parameter reference, so I'm not even sure this is possible. I understand the concept of the ArrayIterator in a ...
oucil's user avatar
  • 4,654
4 votes
2 answers
1k views

How do i clone an ArrayIterator in PHP?

I am trying to clone an \ArrayIterator object, but it seems like the cloned one is still referencing to the original one. $list = new \ArrayIterator; $list->append('a'); $list->append('b'); $...
Eimihar's user avatar
  • 135
0 votes
3 answers
156 views

How to get the intersection of two arrays by keys?

I want to save certain values from $_POST into a file. But I only want values where the key is in the array $lang. As an example: $_POST = [1 => "a", 2 => "b", 3 => "c"]; $lang = [2, 3]; ...
Don Laknath's user avatar

15 30 50 per page