Home » Php » php – Printing only a part of an array

php – Printing only a part of an array

Posted by: admin February 25, 2020 Leave a comment


I have something I’m working on where I’m trying to display a tracking number from an order in a table on a “My Account” page. I was able to get everything and I’m so close, but I can’t seem to figure out arrays with my limited knowledge of PHP.

    if ( $value = $order->get_meta( '_wc_shipment_tracking_items' ) ) {
        print_r( $value );

And that displays:

Array ( 
    [0] => Array ( 
        [tracking_provider] => fedex,
        [tracking_number] => 99999999999,
        [date_shipped] => 1581552000,
        [tracking_id] => 6c382ea3f6d8b1e217599eb95dda7dab 

How would I be able to display just that tracking number, and better yet, could I get it as a link to track it on fedex?

How to&Answers:

echo $value[0][‘tracking_number’]