37 questions
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 ...
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 ...
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 ...
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 (...
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,
...
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' =&...
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 ...
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>();
....
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 ...
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 ...
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 },...
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-&...
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 ...
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');
$...
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];
...