This file contains hidden or 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 | |
$array = array( | |
"Events", | |
"Webinars", | |
"Cloud", | |
"Collaboration", | |
"Innovation", | |
"Tips" | |
) |
This file contains hidden or 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
# OPTION 1 | |
# array_a is an array that holds what will become the keys in the new hash. | |
# array_b is an array that holds what will become the values in the new hash. | |
# Create a new empty hash. | |
my_hash = {} | |
# Send array_a and array_b into the new hash. | |
array_a.each_with_index { |key, value| my_hash[key] = array_b[value] } | |
# This works well for arrays that have the same amount of content so that things | |
# line up. I haven't researched what happens with one array has more content | |
# than the other. |
This file contains hidden or 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
# This works in IRB but I could not get it to output in a browser. The command | |
# 'puts' will not output to a browser but with other methods, doing something | |
# like '{ |x| x}' usually works but not here. | |
hash.each_key { |x| puts x } | |
#This works to output to a browser. The output is an array. | |
hash.key |
This file contains hidden or 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
#Example 1 | |
$myvariable= imgarray.map do |layouts| | |
layouts[ 'layouts' ].map do |layout_name| | |
layout_name[ 'layout_name' ] | |
end | |
end | |
#Placing the variable at the beginning of the loop returns an array within an array: | |
#[["annie", "billy", "charlie", "danny", "eddy", "fergie", "granny", "henry", "jenny", "kelsey"]] | |
#Example 2 |
This file contains hidden or 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
#Code with block | |
$myvariable= imgarray.map do |layouts| | |
layouts[ 'layouts' ].map do |layout_name| | |
layout_name['layout_name'] | |
end | |
end | |
#Code on one line | |
$myvariable= (imgarray.map{ |layouts| (layouts[ 'layouts' ]).map{ |layout_name| (layout_name[ 'layout_name' ]) }} ) |
This file contains hidden or 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
<%= 'filexyz ' + (filexyz.class).to_s %> #>filexyz String | |
<%= (['filexyz'] + [filexyz.class]).join(" ") %> #>filexyz String |
This file contains hidden or 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
<%= hobbiestostring = '[' + (friends.map{ |friend| (friend[ 'children' ]).map{ |nino| nino[ 'name'] }}).join(", ") + ']' %> |
This file contains hidden or 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
<% | |
for item in ids | |
puts item | |
end | |
%> | |
<% | |
ids.each do |item| | |
puts item | |
end |
This file contains hidden or 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
#Each statements do not allow their variables to be used outside of the statement. | |
<%= friends.each{|friend| friend['children']} %> | |
#To do this use `do`. | |
<% friends.each do | |
|friend| @uno = friend['name'] | |
end %> | |
<%= "#{@uno}" %> |
This file contains hidden or 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
// remap jQuery to $ | |
(function($){ | |
// Can also be used with $(document).ready() | |
$(window).load(function() { | |
$('#navs-menu').click(function () { | |
$('.nav-menu').slideToggle(300); |