Skip to content

Commit

Permalink
Merge pull request #7 from julkwel/master
Browse files Browse the repository at this point in the history
add js array function
  • Loading branch information
julkwel authored May 12, 2019
2 parents 938fa0a + 77a0967 commit d4d845a
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 4 deletions.
5 changes: 1 addition & 4 deletions .gitignore
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
Expand Down
34 changes: 34 additions & 0 deletions algo-csv-php.md
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
}
}
}
```
125 changes: 125 additions & 0 deletions index.js
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);
})

0 comments on commit d4d845a

Please sign in to comment.