Created
August 8, 2014 12:44
-
-
Save jonatanrdsantos/ae86c5e70fb2c9be628b to your computer and use it in GitHub Desktop.
Montando array Multidimencional a partir de múltiplo de outro array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$elementData = []; | |
$tmp_elem = ''; | |
//vare todo o array que contem os dados | |
for($i=0;$i<=count($data);$i++) { | |
if( !is_null($data[$i]) ) { | |
//clcula o multiplo e joga os dados no devido lugar | |
switch ($i % 3) { | |
case 0: | |
$tmp_elem['key'] = $data[$i]; | |
break; | |
case 1: | |
$tmp_elem['value'] = $data[$i]; | |
break; | |
case 2: | |
$tmp_elem['minimo'] = $data[$i]; | |
array_push($elementData,$tmp_elem); | |
break; | |
} | |
} | |
} | |
$this->_elementData = $elementData; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment