How to select several?

Asked

Viewed 54 times

0

I’m trying to assign [0] to[1] to[2] and[3] to the id variable... How do I?

What I tried to do was this:

$id = $nas[0,1,2,3]
  • 1

    Explain better: you want to have too $id[0] ... $id[3]? What will you do with the id?

1 answer

2


for ($i = 0; $i < count($nas); $i++) {
    $id = $nas[$i];
}
  • i should start with 0 to go through all elements of the array, be as long as it is smaller and not smaller or equal, and until Count of the nas, not to be limited to picking 3 items.. -1

  • Kkkk True, I ended up giving a wrong there but I already corrected, Thank you. Personal opinion: I just thought it was unnecessary to take the point there because it was just a typo, but anyway?!.

  • The -1 is required, it is nothing personal but rather according to the quality of the answer, it can still improve by placing the condition as ' $i < Count($nas)e eliminando a minhai = 0;` because besides having syntax error is unnecessary. But thanks, for taking as constructive criticism bro, some people do not accept

  • I edited the answer, now yes +1

  • 1

    Whoops, thanks guy kkkk.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.