-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from julkwel/master
add js array function
- Loading branch information
Showing
3 changed files
with
160 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,7 @@ | ||
|
||
|
||
|
||
###> symfony/phpunit-bridge ### | ||
.phpunit | ||
/phpunit.xml | ||
|
||
###> IDE ### | ||
/.idea | ||
/.DS_Store | ||
/.vscode | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
``` | ||
/** | ||
* @Var $fileType | ||
**/ | ||
$_form_upload = $this->createFormBuilder()->add('file', FileType::class)->getForm(); | ||
$your_big_array = array(); | ||
$_file = _form_upload['file']->getData(); | ||
/** | ||
* Check if file | ||
**/ | ||
if (($h = fopen("{$_file}", "r")) !== FALSE) { | ||
while (($data = fgetcsv($h, 1000, ",")) !== FALSE) { | ||
// set data equals to your init array | ||
$your_big_array[] = $data; | ||
} | ||
/** | ||
* Shift the first array if not needed | ||
**/ | ||
array_shift($your_big_array); | ||
// foreach your big array content | ||
foreach ($your_big_array as $value) { | ||
// Your own logique to set data | ||
for ($a = 0; $a < count($your_big_array); $a++) { | ||
// your own logique to insert data | ||
} | ||
} | ||
} | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
/** | ||
* Type des données primitifs | ||
* | ||
* Boolean -> résultats assertion logique -> true pour vraie logique , false pour faux logique | ||
* Null -> Valeur null | ||
* Undefined -> non défini | ||
* number -> nombre | ||
* string -> chaine de caractere | ||
* | ||
* Type objet | ||
*/ | ||
|
||
/** | ||
* New array | ||
*/ | ||
var test = new Array(1,2,4) | ||
|
||
/** | ||
* Create array from params{any} | ||
*/ | ||
Array.from(params) | ||
|
||
/** | ||
* Create array from args{any} | ||
*/ | ||
Array.of(1,"1"); | ||
|
||
/** | ||
* Operate right to left | ||
*/ | ||
test.reduce(( item, value ) => item + value, 1) | ||
|
||
/** | ||
* Check if item is operate by function params | ||
* Bool | ||
*/ | ||
test.some( item => item < 6) | ||
|
||
/** | ||
* Check if all element is passed by test | ||
* Bool | ||
*/ | ||
test.every( item => item < 5) | ||
|
||
/** | ||
* Find element in array | ||
* Bool | ||
*/ | ||
test.includes(2) | ||
|
||
/** | ||
* Concat array with other value | ||
*/ | ||
test.concat(new Array(6,8)) | ||
|
||
/** | ||
* Filtre | ||
*/ | ||
test.filter( item => item < 8 ) | ||
|
||
/** | ||
* Sort descending | ||
*/ | ||
test.sort((a , b ) =>a < b ? 1 : -1 ) | ||
|
||
/** | ||
* Sort ascending | ||
*/ | ||
test.sort(( a , b )=> a < b ? -1 : 1 ) | ||
|
||
/** | ||
* Push element to array | ||
*/ | ||
test.push() | ||
|
||
/** | ||
* Remove element in middle of array | ||
*/ | ||
test.splice(0,2) | ||
|
||
/** | ||
* Couper un array | ||
*/ | ||
test.slice(0,3) | ||
|
||
/** | ||
* Add element in middle of array | ||
*/ | ||
test.splice(1,2,"Hihi") | ||
|
||
// Difference betwen this splice is the third parameters means add value | ||
|
||
/** | ||
* add element at first | ||
*/ | ||
test.unshift("a") | ||
|
||
/** | ||
* Remove first element | ||
*/ | ||
test.shift() | ||
|
||
/** | ||
* remove last element | ||
*/ | ||
test.pop() | ||
|
||
/** | ||
* Append all element | ||
*/ | ||
test.toString() | ||
|
||
/** | ||
* Join array with string | ||
*/ | ||
test.join('-') | ||
|
||
/** | ||
* Itterate the array then add the provide function in all item | ||
*/ | ||
test.map(item => item + 1) | ||
|
||
test.forEach(function(item,index){ | ||
console.log(item,index); | ||
}) |