Right now I'm reading Agile Web Development with Rails. I'm very new to ruby, and come from a mainly php background.

I'm having trouble with the following ruby syntax:

 def add_product(product)
   item = @items.find {|i| i.product_id == product.id}
   if item
 	item.quantity += 1
 	item = LineItem.for_product(product)
 	@items << item
   @total_price += product.price
Now, you don't have to know exactly what this function is doing. Basically, it's adding an item to a shopping cart. I'm having trouble understanding the syntax in the bolded line though.

Would anyone be so kind as to rewrite that bolded line in PHP?

Is "item" in that line an array? Or is it supposed to be true, false or nil? Where is |i| coming from? I know that || is a pipe, but I don't really understand the concept.

One more question: With "if item", is that the same as "if (!empty($item))" in php?