Questions tagged as 'foreach'

1
answer

Receive array values

How do I get the values for this checkbox? <input type="checkbox" name="Item[<?php echo $IDCatalogo; ?>][<?php echo $IDItem; ?>]"> foreach( $_POST['Item'] as $key => $n ) { print "<p>".$n." | ".$key....
asked by 19.09.2015 / 20:39
1
answer

Using else inside foreach

Personal I have the following code: <?php $string = $_POST['search']; foreach($results['results']['collection1'] as $collection) { if(stristr($collection['prod']['text'],$string) !== false) { echo "<div class='col-lg-4 col...
asked by 02.08.2015 / 19:45
1
answer

How to return array indexes in method

Well I could not find a better title for my case, I have the following function : public function select_tokens() { $sql = "SELECT * FROM 'users'"; $select_tokens = Database::DB()->prepare($sql); $select_tokens->execute();...
asked by 31.07.2017 / 12:57
2
answers

How to use data from an Array without foreach

I have a function in my Model : public function get_learning_category_list() { $categorias = $this->db->select('t1.id, t1.title, t1.metadata, t1.meta_title, t1.description, t1.meta_description, t1.meta_spam, t1.url, t1.alt_img...
asked by 08.04.2015 / 16:06
1
answer

Codeigniter: retrieve array values out of loop

I have a problem storing the array values in the code below: public function get_submenu() { $query = $this->db->get_where('categories', array('category_id_parent' => 0)); foreach ($query->result() as $row): $cat_i...
asked by 03.07.2014 / 10:50
1
answer

Error with Foreach arguments

I created a structure with some loops however php is returning me that the foreach arguments are invalid ... I'm not sure if this structure is correct, so I would like someone to inform me if this is correct: p> for($x=1; x<=$n_cartelas_regi...
asked by 04.09.2014 / 04:16
2
answers

How do I join results from different foreach in an array?

I'm getting movie info from a movie site using Simple Html Dom. <?php include("simple_html_dom.php"); $html = file_get_html("http://arcoplex.com.br/?lang=059"); To get the titles of the movies I do: foreach($html->find('.Cartaz .f...
asked by 24.09.2018 / 19:15
1
answer

I can not start an array with foreach

I can not print my array when I put a different key, it gives the error Warning: Invalid argument supplied for foreach (), how to proceed? for ($i=0; $i < 2; $i++) { $use[$i]['outrachave'] = 'some valor'; for ($j=0; $j < 2 ;...
asked by 21.06.2018 / 15:30
1
answer

Foreach inside foreach is duplicating PHP values? [closed]

I'm having a problem with looping , I'm working with 3 Bank tables, it would be Anuncio , Opcoes_Anuncio ( interleave) and Opcoes , I'm trying to get data from options together with the selected options, but it happens t...
asked by 15.05.2018 / 23:31
1
answer

Merge records in foreach

I'm doing a record listing and I'm having the following difficulty: On my system I have two tables and I need to list their records in an interleaved way. The location of the listing is the same. Only I can not make a foreach to list one a...
asked by 15.02.2018 / 16:56