Questions tagged as 'array'

2
answers

Remove input from an array by its value

To remove an entry from an array, we can use the unset () function: / p> <?php $arr = array(1, 2); unset($arr[0]); var_dump($arr); /* Resultado: array(1) { [1]=&gt; int(2) } */ ?> Question How to remove an entry from an...
asked by 28.01.2014 / 00:45
2
answers

Dynamic Array in JavaScript

I'm trying to dynamically generate an array arrays . For example: check = function (title, filter) { if (checked.indexOf(title) !== -1) { checked[title].push(filter); } else { checked.push(title);...
asked by 11.11.2014 / 21:28
2
answers

preg_split is not breaking the strings in the array

I'm not able to use the preg_split() function correctly. I'm trying to break a String in a array() via regex but it's not rolling. $string = "<:termo.9:><:termo.10:><:termo.11:>"; $res = preg_split("/(<:)...
asked by 30.09.2015 / 23:02
1
answer

Value comparison within date frame

Hello, I have a database, with about 50000 observation, as follows, just figurative values: nome<-c("joão","pedro", "joãoo") identificador<-c(123456,124578,123456) valor<-c(2145,350,23) dados=data.frame(nome,identificador,valor) I...
asked by 14.03.2017 / 20:38
1
answer

In R, when a vector becomes "too long"?

When trying to create an infinite vector ( 1:Inf ) I received the following message:    Error in 1: Inf: result would be too long to vector However, when the vector does not know in memory the message is usually different. The code...
asked by 02.03.2017 / 18:18
2
answers

Read text file and play content in positions in an array!

I am in doubt that I can read a .txt file and store its data in different positions in a array . The file is saved as follows: city=A(100,80); city=B(160,70); city=C(110,50); city=D(140,120); city=F(155,40); city=G(210,60); cit...
asked by 24.08.2016 / 01:17
1
answer

Saving data to a global array

I'm studying PHP, and so far I've developed a small system that "mounts" site views and so on. But I came across an extremely annoying problem that I can not solve. I need a function to show errors that occur in the system. The problem is...
asked by 23.12.2014 / 17:58
1
answer

Foreach within Foreach PHP

I have the following code: $row = $twitterusers->selectUserAll(); foreach ($row as $fetch) { $users[] = $fetch; } var_dump($users); It takes all the users of the table, however when using var_dump I realize that it has ar...
asked by 25.07.2017 / 14:45
1
answer

Special treatment for string, why?

I know that arrays are static elements used when you have a pre-determined size that can be used. But speaking of initialization, when the size is already set next to the array, I would like to know, essentially, why you can not use other types...
asked by 21.05.2015 / 15:12
2
answers

Output in json with json_encode ()

   json_encode () - Returns the JSON representation of a value If I do: $foo = array('a', 'b', 'c', 'd', 'e'); echo json_encode($foo); I'll get: ["a","b","c","d","e"] So far so good, I'm getting an array and turning it into a json...
asked by 10.11.2015 / 16:18