PHP - split arrays if value 2 is higher than 1 ( -


I have worked hard this night to find out how to divide my arrays into multiple arrays. / P>

I can have this value

  $ array = array (array ("apple", 10), array ("ball", 5));   

Then I want to have 10 arrays in the apple where the value is "apple" and the ball has 5 arrays, where the value is "ball"

Then I It came with this, but production seems very strange ..

  $ newarray = array (); For foreign currency ($ array $ val): ($ i = 1; $ i & lt; = $ val [1]; $ i ++): $ new $ [$ i] = $ val [0]; Endfor; Endforeach; Print_r ($ newarray); Ball [4] = & gt; Ball [4] = & gt; Ball [4] = & gt; Ball [4] = & gt; Ball [5] = & gt; Ball [6] = apple [7] = & gt; Apple [8] = & gt; Apple [9] = & gt; Apple [10] = & gt; Apple)   

Hope you guys will understand my question, and hopefully nobody can understand it.

In advance, thanks.

Here can help:

  $ result = array ( ); Forex Currency ($ $ as Enterprise Sub) {$ Result [] = array_fill (0, $ sub [1], $ sub [0]); } Print_r ($ result);   

See it in verb:

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -