E
E
exedis2016-03-28 16:35:58
PHP
exedis, 2016-03-28 16:35:58

How to display the elements of an array?

Hello, stupid question, but it’s impossible to do the following normally - for example, we have an array of 10 elements {1,2,3,4,5,6,7,8,9,10} we need to display in this order {3,5,7,9,1} exactly like that. Preferably in php, but you can use other languages ​​as an example.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sizoider, 2016-03-29
@Sizoider

people, if it's not difficult, please write a solution in javascript

K
Kocmoc, 2016-03-29
@kocmoc941

// ыыыы
array=[1,2,3,4,5,6,7,8,9,10]
out=''
for(i = 2;i < 10;i += 2)
    out = out + ' ' + array[i];
out = out + ' ' + array[0];  
WScript.echo(out);

N
newpy, 2016-03-29
@newpy

Python

arr = list([x for x in range(2,10) if x % 2 != 0] + [1])
print(arr)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question