Jump to content

Echo from array help


tqla

Recommended Posts

How do I echo the "customer_id" from this array.

 

[appointment] => Array
                (
                    [7] => Array
                        (
                            [id] => 7
                            [session_id] => 3
                            [provider_id] => 96
                            [customer_id] => 95
                            [location_id] => 1
                            [seats] => 1
                            [created_at] => 1274891117
                            [starts_at] => 1275066000
                            [duration] => 900
                            [lead_in] => 900
                            [lead_out] => 900
                            [approved] => 1
                            [no_show] => 0
                            [is_ghost] => 0
                            [service_id] => 2
                            [_invoice] => 7
                        )

                )

Link to comment
https://forums.phpfreaks.com/topic/203219-echo-from-array-help/
Share on other sites

tqla,

 

    Here's a way to do it programatically:

 


<?php

Header("Cache-control: private, no-cache");
Header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
Header("Pragma: no-cache");


	$appointment = array(

					7 => array(

						'id' => 7,
                            'session_id' => 3,
                            'provider_id' => 96,
                            'customer_id' => 95,
                            'location_id' => 1,
                            'seats' => 1,
                            'created_at' => 1274891117,
                            'starts_at' => 1275066000,
                            'duration' => 900,
                            'lead_in' => 900,
                            'lead_out' => 900,
                            'approved' => 1,
                            'no_show' => 0,
                            'is_ghost' => 0,
                            'service_id' => 2,
                            '_invoice' => 7,
                        ),

					8 => array(

						'id' => 8,
                            'session_id' => 4,
                            'provider_id' => 97,
                            'customer_id' => 96,
                            'location_id' => 2,
                            'seats' => 2,
                            'created_at' => 1274891118,
                            'starts_at' => 1275066001,
                            'duration' => 901,
                            'lead_in' => 901,
                            'lead_out' => 901,
                            'approved' => 2,
                            'no_show' => 1,
                            'is_ghost' => 1,
                            'service_id' => 3,
                            '_invoice' => 8,
                        )


                    );

          $display = FALSE;

          if ($display) {

              require_once($toodles . 'includes/debugFunctions.php');
              echo "</script> \n";
              printArray($appointment, '$appointment', __FILE__, __LINE__);

              /**
               *
               *  Returns:
               *
               */

//              	Name :: $appointment :: Reporting from line :: 36 :: in program :: /var/www/html/VAT_DEV/test.php ::
//
//						Array
//						(
//						    [7] => Array
//						        (
//						            [id] => 7
//						            [session_id] => 3
//						            [provider_id] => 96
//						            [customer_id] => 95
//						            [location_id] => 1
//						            [seats] => 1
//						            [created_at] => 1274891117
//						            [starts_at] => 1275066000
//						            [duration] => 900
//						            [lead_in] => 900
//						            [lead_out] => 900
//						            [approved] => 1
//						            [no_show] => 0
//						            [is_ghost] => 0
//						            [service_id] => 2
//						            [_invoice] => 7
//						        )
//
//						    [8] => Array
//						        (
//						            [id] => 8
//						            [session_id] => 4
//						            [provider_id] => 97
//						            [customer_id] => 96
//						            [location_id] => 2
//						            [seats] => 2
//						            [created_at] => 1274891118
//						            [starts_at] => 1275066001
//						            [duration] => 901
//						            [lead_in] => 901
//						            [lead_out] => 901
//						            [approved] => 2
//						            [no_show] => 1
//						            [is_ghost] => 1
//						            [service_id] => 3
//						            [_invoice] => 8
//						        )
//
//						)
//
           			}

foreach($appointment as $IDX => $customerArray) {

	$display = FALSE;

	if ($display) {

	    require_once($toodles . 'includes/debugFunctions.php');
	    echo "</script> \n";
	    printArray($customerArray, '$customerArray', __FILE__, __LINE__);

	    /**
	     *
	     *  Returns:
	     *
	     */

//				Name :: $customerArray :: Reporting from line :: 104 :: in program :: /var/www/html/VAT_DEV/test.php ::
//
//
//					Array
//					(
//					    [id] => 7
//					    [session_id] => 3
//					    [provider_id] => 96
//					    [customer_id] => 95
//					    [location_id] => 1
//					    [seats] => 1
//					    [created_at] => 1274891117
//					    [starts_at] => 1275066000
//					    [duration] => 900
//					    [lead_in] => 900
//					    [lead_out] => 900
//					    [approved] => 1
//					    [no_show] => 0
//					    [is_ghost] => 0
//					    [service_id] => 2
//					    [_invoice] => 7
//					)
//
//				Name :: $customerArray :: Reporting from line :: 104 :: in program :: /var/www/html/VAT_DEV/test.php ::
//
//
//					Array
//					(
//					    [id] => 8
//					    [session_id] => 4
//					    [provider_id] => 97
//					    [customer_id] => 96
//					    [location_id] => 2
//					    [seats] => 2
//					    [created_at] => 1274891118
//					    [starts_at] => 1275066001
//					    [duration] => 901
//					    [lead_in] => 901
//					    [lead_out] => 901
//					    [approved] => 2
//					    [no_show] => 1
//					    [is_ghost] => 1
//					    [service_id] => 3
//					    [_invoice] => 8
//					)


	}

	foreach ($customerArray as $customerIDX => $currentCustomer) {

		if ($customerIDX == 'customer_id') {

			echo "customer_id: " . $customerArray[$customerIDX] . " found for  \$appointment[$IDX] <br /><br/> \n";

		}

	}

}

?>

 

Scot L. Diddle, Richmond VA

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.