Questions tagged as 'array'

2
answers

What do the incrementing operators do in arrays?

I was accidentally creating a PHP script and, unintentionally, put an incremental operator on a variable whose type is array . To my surprise, no error was shown by PHP. I made some tests and found that this really does not generate...
asked by 14.12.2015 / 14:35
1
answer

Vector start with element greater than 0 (zero)?

Usually a vetor starts from element 0 , and so on until it reaches the size of which it was declared or assigned, eg: string[] v = {1, 2 , 3}; // equivalente á: v[0] = 1; v[1] = 2; v[2] = 3; I want to know how to do in C#...
asked by 13.01.2016 / 19:21
1
answer

Assigning a key and a value to an object

I assign the result of an SQL query using PDO ( PDO::FETCH_OBJ ) to a variable, and with that variable I access the query values as if it were an object. Example of an array as an object: <?php $obj = (object) array('foo' =>...
asked by 13.11.2014 / 00:40
1
answer

How to return the index of an array and its value in different variables?

I have an array of the following structure Matriz[indice][valor] How do I return the index in one variable, and the value in another? Exdrúxulo example: $indice = $matriz[indice] And for the value: $valor = $matriz[indice][valor]...
asked by 14.05.2015 / 02:56
2
answers

Find value inside an array

I have the following array: array (size=80) 0 => array (size=2) ‘cod_produto' => int 107 'valor' => float 20 1 =>
 array (size=2) ‘cod_produto' => int 109 'valor'...
asked by 03.05.2018 / 20:15
3
answers

How to remove the last character from the last value of an array

I have the following foreach: $items = ""; foreach ($_POST['termos'] as $item) { if(isset($item)){ $items = $items . $item . '+'; } } It returns me: Array ( [0] => 1-valor+ [1] => 2-valor+ [2] => 3-valor+ ) Q...
asked by 02.03.2015 / 02:05
2
answers

Can I access a variable (not array) in PHP using index 0 as an array?

The case is as follows, I have a function that if something happens it creates an array with n numbers ($x[n]) and if it happens another it stores in a common variable with the same name ($x) . I know I can instead of storing...
asked by 16.03.2015 / 17:44
2
answers

Why do some functions that work with C strings start with *?

In one of our classes we were taught that when a function receives as a parameter a vector, it is actually receiving the memory position in which it is allocated, so it is not necessary to return any value since what will be executed within the...
asked by 28.04.2017 / 16:45
2
answers

Create vector automatically in Python

I'm new to Python and need help with the following: I have a variable (x) that gets an integer value. I want this variable to be used to create a vector with 1 row and (x) columns. This vector must have random integer values from 0 to 10...
asked by 23.04.2017 / 20:34
2
answers

Resize in dynamic pointer transforms dimension into garbage

I was responding to a std :: stack implementation problem. It was easy, but I could not use my first idea: std :: vector (it replaced forever the dynamic pointers). My code is: template <class T> class stack { T* data; unsigned s...
asked by 20.04.2014 / 21:41