Questions tagged as 'array'

2
answers

Checking if value exists in an array via search field

In pure javascript I can use indexOf() , something like this: var chaves = ['wmv','3gp','mp4','mp3','avi']; if(chaves.indexOf("avi") != -1) { alert("Ok!"); } But when it comes to a search field I'm trying this way: <html...
asked by 26.12.2016 / 20:29
2
answers

Remove spaces from an array of String

How do I remove spaces (not all spaces, just the beginning and end) of all the indexes of a String array in Java?     
asked by 21.08.2017 / 20:53
3
answers

Insert months not in the array

I am putting a% of the total sales value per month. The code is working perfectly, but I need to array check which months are not in this array and fill it in order 1 to 12. For example: The code generated an array like this:    [{4...
asked by 31.10.2016 / 19:14
2
answers

How to insert the elements of the array X into an index of the array Y?

I have the array y where in its index 0 has the values App and Views array (size=1) 0 => array (size=2) 0 => string 'App' (length=3) 1 => string 'Views' (length=5) No x I have a...
asked by 14.07.2016 / 18:55
2
answers

Numbers located in odd positions

I should only present the numbers present in the odd positions of the vector, however I'm locked: package pag1; import java.util.Scanner; import java.util.Arrays; public class ex1 { public static void main (String[] args){ Scann...
asked by 03.07.2017 / 07:43
2
answers

Increment variable inside a foreach [closed]

How do I make a variable increment within a foreach ? foreach($adults as $adultos): $i = 1; echo "<strong>Quarto".$i++."</strong><br>"; echo "Adultos:".$adultos."<br>"; endforeach;     
asked by 19.09.2017 / 01:51
2
answers

How to join two array

I need to join two array first array array (size=11) 7100 => boolean false 7108 => boolean false 7110 => boolean false 7120 => boolean false 7130 => boolean false 7140 => boolean false 7150 => boolean false...
asked by 02.03.2017 / 00:01
2
answers

Group items by one field in different arrays

$resultado = $modelSga->getConsultaSga($ano, $mes, $unidade); foreach ($resultado as $res) { $idServico = $res->id_serv; $servico = array(); if($idS...
asked by 31.10.2014 / 16:18
2
answers

Invert array (positions)

I am trying to make an inversion of an array in the C language. For example: I have an array [1, 2, 3] , I need to invert the numbers in the SAME array, giving an output like this: [3,2,1] . I'm trying, but on reaching the...
asked by 07.12.2016 / 20:09
1
answer

Delete repeated words from an array and sort it

I have a certain function that returns me array cluttered with multiple cities repeated. This way: <?php function getArrayCities() { return array("são paulo","rio de janeiro","belo horizonte","recife","fortaleza", "porto alegre",...
asked by 09.01.2017 / 22:34