Question: I wanna know if php can remotely store when the user is logged in such as date and ipaddress, maybe use "COOKIES" or a database, I don't know and I'm not sure. Btw, my question means that if last time I logged on was "4/5/2014 from 108.25.1.123" 

it would echo

* **Last Login: 4/5/2014 from 108.25.1.123**

*ignore the database and cookies if im wrong.*

Answer: 
[`String#gsub`](http://ruby-doc.org/core/String.html#method-i-gsub) accepts an optional block: return value of the block is used as replacement string:

```
melody.gsub(/[CDFGA]#/) { |x| x[0].downcase }
# => "f g a B |a g f   |a B c d |c B a   |f   f   |f   f   |ffggaaBB|a g f   "

```
You can use hash too.

```
melody.gsub(/[CDFGA]#/, {'C#' => 'c', 'D#' => 'd', 'F#' => 'f', 'G#' => 'g', 'A#' => 'a'})

```