Questions tagged as 'foreach'

2
answers

Display only one record with the foreach

I need help to display a record of the database, following code: <?php $posts = DBRead( 'posts', "WHERE categoria = 3 AND status = 1 ORDER BY data_numero ASC" ); if( !$posts ) echo '<h2>Nenhuma Corrida Registrada!<...
asked by 15.01.2017 / 20:19
1
answer

PHP get value from a multidimensional array

$arquivo = '{"nome":"João","cpf":"00000","teste":"ooooo"}'; $dd = json_decode($arquivo, TRUE); foreach($dd as $value) { $nome = $value->{'nome'}; $cpf = $value->{'cpf'}; } I want to get the value of name and cpf from the array but th...
asked by 22.01.2017 / 19:36
1
answer

Add item in array with PHP foreach

I need to get the PHP foreach , the question id , and the answer of each question answered. I can only get the id of the question, how would I also get the answer typed? My foreach <? if (isset($_POST['resposta'])) { foreach...
asked by 11.10.2018 / 20:26
1
answer

How to traverse an object and filter this object?

I'm trying to navigate an object and after that, filter the same. I'm using this code, but it's not working. Can anyone help me and if possible explain the code? const objeto = { idade: 20, idade:20, idade:21}; const funcao =...
asked by 22.01.2018 / 19:25
1
answer

How to do list all of xml to php

Good evening. I have the following xml file: <MusicHistory CompactMode="1"> <Item0 Block="2018-02-11T23:00:00" Folder="Musicas" Music="Zara Larsson - So Good" Composer="" Comment="" Start="2018-11-03T02:19:13.000Z"/> <Item1 Bloc...
asked by 03.11.2018 / 03:25
2
answers

How to make an @foreach with Table Relationship in Laravel

I'm using the Laravel freamwork where in my database I have 2 tables:  - > claimants (with the field 'id', 'claimant', 'type_id')  - > types (with the fields 'id', 'name') Both are already with the Complainant Model Relationship publi...
asked by 27.09.2018 / 02:58
1
answer

Foreach taking only the last record

I'm developing a supplier registration screen, but my foreach is only getting the last record for a total of 3 records. What could I be doing wrong? Below my code and attached to my screen. Many thanks <thead><trstyle="background...
asked by 30.08.2018 / 04:50
1
answer

Picking indexes with equal keys from a non-associative array

How do I get / group indexes with equal keys in an array, for example: Array ( [field_label] => Array ( [0] => Texto [1] => Checkbox [2] => URL ) [field_type] => Array...
asked by 12.08.2018 / 19:57
2
answers

How to remove null value from a foreach or array

I'm doing a query on a table that has a blank value (student: note). In a page I do the function with select and set the array on a return to call on another page, but I can not delete the blank value to print only those that have data. $valor...
asked by 14.06.2018 / 15:55
1
answer

Filling index of non-existent results of a select with 0

I make a select in the database which returns me a array of data. With this, I make the following foreach on it: foreach ($resultado4 as $key => $value7) { $array6[$value7['carteira'].'flores'] = $value7['floresqt...
asked by 01.06.2018 / 19:37