How to iterate an array a certain number of times in PHP in Codeigniter?

Asked

Viewed 22 times

-1

I have 2 arrays, a blank( let’s call tenStatesArray) that I want to contain 10 values and another containing 26 values( let’s call statesArray). How to pass the first 10 elements of this array containing 26 to tenStatesArray ?

1 answer

0


Whereas you want the first 10 elements, you can use the function array_slice php native.

$tenStatesArray = array_slice($statesArray, 0, 10);

Browser other questions tagged

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