Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add js array function #7

Merged
merged 5 commits into from May 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 1 addition & 4 deletions .gitignore
@@ -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
@@ -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
@@ -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);
})