Summary: Hi Everyone in this post I am trying to cover all git commands for the beginner with little description. I am pretty sure that I would help you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
git log --grep="javascript" // search for a commit description name git log HEAD git log --oneline ---> to see the log in one line git log --graph --oneline --decorate --all // to see the log with the branch name git diff git diff filename (if want see specfic file changes) git checkout --filename git reset HEAD filename git commit --amend -m "message" (add some changes to the last commit) git checkout hash(1lml5554) ---> after this need to commit again git revert hash(1lml5554) ---> It is total revert the code cat .git/HEAD git reset HEAD filename ---> to remove of reset old changes. git reset --soft hash ---> to point the head on the code. git reset --mix hash git reset --hard hash git clean filename ---> to remove untracked files permanently. To add the tracked file into gitignor git rm --cached filename git branch --->check the current branch git branch branch_name ---> to create the new branch git checkout branch_name ---> to switch to the new branch git checkout -b branch_name ---> create and switch to the new branch git diff master..branch_name --> to check diff b/w two branches git diff --color-words master..branch_name --> to check diff b/w two branches with git branch merged ---> this show us the branches that merged in the current branch git branch -m branch_name new_branch_name // to rename branch name Merging git merge branch_name // first checkout to receiver branch the write branch_name that to be merge git branch --merged // to check merged branch git show HEAD |
Summary: Hi, everyone. In this post I am going to show you how we can group by in array PHP by using foreach loop. We have no defalut function for groupby of array in php. Let’s start, We have a array which contain Items in key and It’s owner in value.
1 2 3 4 5 |
[ "Item1" => "Randy", "Item2" => "Stan", "Item3" => "Randy" ]; |
But we need to show result like below:
1 |
[ "Randy" =>["Item1","Item3"],"Stan"=>["Item2"] ]; |
Let’s do it. First of all, I take an empty array named $newArray. Take array in a variable
$group apply foreach loop. As I show below:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$group=[ "Item1" => "Randy", "Item2" => "Stan", "Item3" => "Randy" ]; $newArray=[]; foreach($files as $key=>$val) { $newArray[$val][] = $key; //storing value in new array according to key } print_r($newArray); |
In result, we got what we want. You can try here(link ) with the live demo.
That’s all! 🙂
Still, face any problem you can post your comment below we definitely help you 🙂