If you are trying to Store Multidimensional Array in Mysql  in a one column than you can use the following code hope that will help you to serialize array & you can get by using the unserialize method.

//array complexity
		
		$settings_arry = array();
		
		$ghj = false;
		if($mixarr['calculator_type'] == 'dimension'){
			$ghj = true;
		}
		
	
		if($ghj == 1){
	
		
		// the type of calculator enabled, one of 'dimension', 'area', etc or empty for disabled
		$settings_arry['calculator_type'] = $mixarr['calculator_type'];

		$settings_arry['dimension']['pricing'] = array(
			'enabled'        => $mixarr['dimension_pricing_enabled_yes_no'],
			'label'          => $mixarr['dimension_pricing_enabled_label'],
			'unit'           => $mixarr['dimension_pricing_enabled_unit'],
			'calculator'     => array(
				'enabled' => $mixarr['dimension_pricing_calculator_enabled'],
			),
			'inventory'      => array(
				'enabled' => $mixarr['dimension_pricing_inventory_enabled'],
			),
			'weight'         => array(
				'enabled' => $mixarr['dimension_pricing_weight_enabled'],
			),
			'overage'        => $mixarr['dimension_pricing_overage'],
		);
		$settings_arry['dimension']['length'] = array(
			'enabled'          => $mixarr['dimension_length_enabled_yes_no'],
			'label'            => $mixarr['dimension_length_enabled_label'],
			'unit'             => $mixarr['dimension_length_enabled_unit'],
			'editable'         => $mixarr['dimension_length_enabled_editable'],
			'options'          => '',
			'accepted_input'   => $mixarr['dimension_length_enabled_accepted_input'],
			'input_attributes' => '',
		);
		$settings_arry['dimension']['width'] = array(
			'enabled'          => $mixarr['dimension_width_enabled_yes_no'],
			'label'            => $mixarr['dimension_width_enabled_label'],
			'unit'             => $mixarr['dimension_width_enabled_unit'],
			'editable'         => $mixarr['dimension_width_enabled_editable'],
			'options'          => '',
			'accepted_input'   => $mixarr['dimension_width_enabled_accepted_input'],
			'input_attributes' => '',
		);
		$settings_arry['dimension']['height'] = array(
			'enabled'          => $mixarr['dimension_height_enabled_yes_no'],
			'label'            => $mixarr['dimension_height_enabled_label'],
			'unit'             => $mixarr['dimension_height_enabled_unit'],
			'editable'         => $mixarr['dimension_height_enabled_editable'],
			'options'          => '',
			'accepted_input'   => $mixarr['dimension_height_enabled_accepted_input'],
			'input_attributes' => '',
		);

		// simple area calculator
		$settings_arry['area']['pricing'] = array(
			'enabled'        => 'no',
			'label'          => '',
			'unit'           => 'sq cm',
			'calculator'     => array(
				'enabled' => 'no',
			),
			'inventory'      => array(
				'enabled' => 'no',
			),
			'weight'         => array(
				'enabled' => 'no',
			),
			'overage'        => 0,
		);
		$settings_arry['area']['area'] = array(
			'label'            => 'Required Area',
			'unit'             => 'sq cm',
			'editable'         => 'yes',
			'options'          => '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);

		// area (LxW) calculator
		$settings_arry['area-dimension']['pricing'] = array(
			'enabled'        => 'no',
			'label'          => '',
			'unit'           => 'sq cm',
			'calculator'     => array(
				'enabled' => 'no',
			),
			'inventory'      => array(
				'enabled' => 'no',
			),
			'weight'         => array(
				'enabled' => 'no',
			),
			'overage'        => 0,
		);
		$settings_arry['area-dimension']['length'] = array(
			'label'            => 'Length',
			'unit'             => 'cm',
			'editable'         => 'yes',
			'options'          => '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);
		$settings_arry['area-dimension']['width'] = array(
			'label'            => 'Width',
			'unit'             => 'cm',
			'editable'         => 'yes',
			'options'          => '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);

		// Perimeter (2L + 2W) calculator
		$settings_arry['area-linear']['pricing'] = array(
			'enabled'        => 'no',
			'label'          => '',
			'unit'           => 'cm',
			'calculator'     => array(
				'enabled' => 'no',
			),
			'inventory'      => array(
				'enabled' => 'no',
			),
			'weight'         => array(
				'enabled' => 'no',
			),
			'overage'        => 0,
		);
		$settings_arry['area-linear']['length'] = array(
			'label'            => 'Length',
			'unit'             => 'cm',
			'editable'         => 'yes',
			'options'          => '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);
		$settings_arry['area-linear']['width'] = array(
			'label'            => 'Width',
			'unit'             => 'cm',
			'editable'         => 'yes',
			'options'          => '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);

		// Surface Area 2(LW + WH + LH) calculator
		$settings_arry['area-surface']['pricing'] = array(
			'enabled'        => 'no',
			'label'          => '',
			'unit'           => 'sq cm',
			'calculator'     => array(
				'enabled' => 'no',
			),
			'inventory'      => array(
				'enabled' => 'no',
			),
			'weight'         => array(
				'enabled' => 'no',
			),
			'overage'        => 0,
		);
		$settings_arry['area-surface']['length'] = array(
			'label'            => 'Length',
			'unit'             => 'cm',
			'editable'         => 'yes',
			'options'          =>  '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);
		$settings_arry['area-surface']['width'] = array(
			'label'            => 'Width',
			'unit'             => 'cm',
			'editable'         => 'yes',
			'options'          =>  '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);
		$settings_arry['area-surface']['height'] = array(
			'label'            => 'Height',
			'unit'             => 'cm',
			'editable'         => 'yes',
			'options'          => '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);

		// Simple volume calculator
		$settings_arry['volume']['pricing'] = array(
			'enabled'        => 'no',
			'label'          => '',
			'unit'           => 'ml',
			'calculator'     => array(
				'enabled' => 'no',
			),
			'inventory'      => array(
				'enabled' => 'no',
			),
			'weight'         => array(
				'enabled' => 'no',
				),
			'overage'        => 0,
		);
		$settings_arry['volume']['volume'] = array(
			'label'            => 'Required Volume',
			'unit'             => 'ml',
			'editable'         => 'yes',
			'options'          => '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);

		// volume (L x W x H) calculator
		$settings_arry['volume-dimension']['pricing'] = array(
			'enabled'        => 'no',
			'label'          => '',
			'unit'           => 'ml',
			'calculator'     => array(
				'enabled' => 'no',
			),
			'inventory'      => array(
				'enabled' => 'no',
			),
			'weight'         => array(
				'enabled' => 'no',
			),
			'overage'        => 0,
		);
		$settings_arry['volume-dimension']['length'] = array(
			'label'            => 'Length',
			'unit'             => 'cm',
			'editable'         => 'yes',
			'options'          => '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);
		$settings_arry['volume-dimension']['width'] = array(
			'label'            => 'Width',
			'unit'             => 'cm',
			'editable'         => 'yes',
			'options'          => '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);
		$settings_arry['volume-dimension']['height'] = array(
			'label'            => 'Height',
			'unit'             => 'cm',
			'editable'         => 'yes',
			'options'          => '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);

		// volume (A x H) calculator
		$settings_arry['volume-area']['pricing'] = array(
			'enabled'        => 'no',
			'label'          => '',
			'unit'           => 'ml',
			'calculator'     => array(
				'enabled' => 'no',
			),
			'inventory'      => array(
				'enabled' => 'no',
			),
			'weight'         => array(
				'enabled' => 'no',
			),
			'overage'        => 0,
		);
		$settings_arry['volume-area']['area'] = array(
			'label'            => 'Area',
			'unit'             => 'sq cm',
			'editable'         => 'yes',
			'options'          => '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);
		$settings_arry['volume-area']['height'] = array(
			'label'            => 'Height',
			'unit'             => 'cm',
			'editable'         => 'yes',
			'options'          => '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);

		// simple weight calculator
		$settings_arry['weight']['pricing'] = array(
			'enabled'        => 'no',
			'label'          => '',
			'unit'           => 'kg',
			'calculator'     => array(
				'enabled' => 'no',
			),
			'inventory'      => array(
				'enabled' => 'no',
			),
			'weight'         => array(
				'enabled' => 'no',
				),
			'overage'        => 0,
		);
		$settings_arry['weight']['weight'] = array(
			'label'            => 'Required Weight',
			'unit'             => 'kg',
			'editable'         => 'yes',
			'options'          => '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);

		// the wall calculator is just a bit of syntactic sugar on top of the Area (LxW) calculator
		$settings_arry['wall-dimension']['pricing'] = array(
			'enabled'        => 'no',
			'label'          => '',
			'unit'           => 'sq cm',
			'calculator'     => array(
				'enabled' => 'no',
			),
			'inventory'      => array(
				'enabled' => 'no',
			),
			'weight'         => array(
				'enabled' => 'no',
			),
			'overage'        => 0,
		);
		$settings_arry['wall-dimension']['length'] = array(
			'label'            => 'Distance around your room',
			'unit'             => 'cm',
			'editable'         => 'yes',
			'options'          => '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);
		$settings_arry['wall-dimension']['width'] = array(
			'label'            => 'Height',
			'unit'             => 'cm',
			'editable'         => 'yes',
			'options'          => '',
			'accepted_input'   => 'free',
			'input_attributes' => '',
		);
		//echo '<pre>';
		//print_r($settings_arry);
		
		}


if($ghj == 1){
		update_post_meta ($post_id, '_wc_price_calculator', $settings_arry);
       
 }

WordPress has own functionality to convert array to serialized but in core php I believe the use of serialize() and unserialize() functions.

Please login or Register to submit your answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.