Accessing Drupal array values I'm noobing my way through countless websites trying to find an answer to accessing a value in a Commerce field array.

I somehow managed to throw together the following code to retrieve a value for a workflow rule I'm writing:

$product_id = $current_line_item-&gt;commerce_product;


The result is: array(1) { ["und"]=&gt; array(1) { [0]=&gt; array(1) { ["product_id"]=&gt; string(2) "14" } } }

I can't figure out how to get any deeper into the array than that. I need to return the product_id value in this array.

Can anyone guide me on the best way to do this?
Devel is super useful to help you figure out these type of things.

Once enabled, you can write dpm($product_id) and it will print out a nice organized structure of the array.  From there, you can click on any item and it will show you how you can access the item like ['und'][0]['product_id'] in your example.

Depending on what exactly you're trying to do, there may be different ways to get the info you need.