Questions tagged as 'foreach'

2
answers

Sort foreach in php

I made a page that shows the hash in several hash_algos in order to study their differences, however I would like to sort by the size of the hash and not by the name of the hash_algos, the code is this, <?php foreach (hash_algos() as $hash_...
asked by 12.10.2017 / 18:12
2
answers

How to create dynamic columns with Bootstrap and PHP?

I have 30 itens that will come in alphabetical order. I need to distribute these items in 3 columns in alphabetical order VERTICAL . The problem is that in Bootstrap , the blocks will marry next to each other causing the...
asked by 12.01.2016 / 21:03
2
answers

Inserting index and value into a two-dimensional array

I have a two-dimensional array (it contains data coming from the database). To traverse this data, I use a foreach (). I need to add an index and a value to this index at the end of each iteration of foreach (). Imagining as if it were an arr...
asked by 19.10.2017 / 18:40
3
answers

Problem with concatenation of variable

I have a variable in a foreach that takes the id of the record: $id_inscrito = $this->session->userdata('last_id'); I want to store this variable in another: $ids_ = $id_inscrito.'|'.$id_inscrito; Give me the result in...
asked by 04.02.2015 / 22:15
1
answer

More than one list in the same loop

Can I put more than one list in the same loop ? for example, you can put more than one variable in for : for (int a, b; a<10 b<20; a++ b++) { ....... } Then I wanted to put more than one list in the same foreach : fo...
asked by 24.03.2018 / 22:17
1
answer

Error: Invalid argument supplied for foreach ()

I'm having a problem displaying my scrapbook, giving this error: Warning: Invalid argument supplied for foreach() in /###/###/###/view/list.php on line 11 The file looks like this: <div class="container marketing"> <?php for...
asked by 26.10.2017 / 18:36
2
answers

Insert multiple with PDO php and MySql

My situation, A POST form with a text input and two input radios. Inputs are named respectively nome[0] and tipo[0] . When someone adds more fields to the form, I put .attr to get nome[1] and tipo[1]...
asked by 29.01.2018 / 02:27
2
answers

How to assign values to an associative array in php?

In an array, for example: $arr = array('item1', 'item2' ... 'itemN'); I want to assign a value to each item. For this, I tried a foreach: foreach($arr as $a => $b) $b = 4; but is informed by the IDE (phpStorm) that the unused lo...
asked by 21.09.2016 / 16:44
2
answers

PHP - Foreach self-tuning

During development, there are many times when a request is made to the database, in which the returned data comes in array, sometimes it is necessary to perform a foreach to adjust this data or even include more data of according to a spe...
asked by 18.09.2015 / 19:24
1
answer

map.forEach Unexpected return value

I have the following map: private static Map<ParseCreator, Parseable> map = new HashMap<>(); I run this map as follows: for (Map.Entry<ParseCreator, Parseable> entry : map.entrySet()) { ParseCreator creator = ent...
asked by 09.05.2018 / 13:52