passing a lot of data for calculating
well pro's i have made this in my code without function so i hade to triple this code. now i need help how to make it with function for a better code. 

                  $sub_pesos1 = ($object->num_piezas_a * $object->cost_pes_a);
		$sub_dolares1 = ($object->num_piezas_a * $object->cost_dol_a);
		$sub_pesos2 = ($object->num_piezas_b * $object->cost_pes_b);
		$sub_dolares2 = ($object->num_piezas_b * $object->cost_dol_b);
		$sub_pesos3 = ($object->num_piezas_c * $object->cost_pes_c);
		$sub_dolares3 = ($object->num_piezas_c * $object->cost_dol_c);
		$sub_pesos4 = ($object->num_piezas_d * $object->cost_pes_d);
		$sub_dolares4 = ($object->num_piezas_d * $object->cost_dol_d);
		$sub_pesos5 = ($object->num_piezas_e * $object->cost_pes_e);
		$sub_dolares5 = ($object->num_piezas_e * $object->cost_dol_e);
		$total = ($object->num_piezas_a + $object->num_piezas_b + $object->num_piezas_c + $object->num_piezas_d + $object->num_piezas_e);
		$sub_pesos = ($sub_pesos1 + $sub_pesos2 + $sub_pesos3 + $sub_pesos4 + $sub_pesos5);
		$sub_dolares = ($sub_dolares1 + $sub_dolares2 + $sub_dolares3 + $sub_dolares4 + $sub_dolares5);


how can i make a function in the class and every time that i need this calculation (or a better code of calculation) i don't have to copy all this code??? 

thank's ahead
passing a lot of data for calculating
===

well pro's i have made this in my code without function so i hade to triple this code. now i need help how to make it with function for a better code. 

                  $sub_pesos1 = ($object->num_piezas_a * $object->cost_pes_a);
		$sub_dolares1 = ($object->num_piezas_a * $object->cost_dol_a);
		$sub_pesos2 = ($object->num_piezas_b * $object->cost_pes_b);
		$sub_dolares2 = ($object->num_piezas_b * $object->cost_dol_b);
		$sub_pesos3 = ($object->num_piezas_c * $object->cost_pes_c);
		$sub_dolares3 = ($object->num_piezas_c * $object->cost_dol_c);
		$sub_pesos4 = ($object->num_piezas_d * $object->cost_pes_d);
		$sub_dolares4 = ($object->num_piezas_d * $object->cost_dol_d);
		$sub_pesos5 = ($object->num_piezas_e * $object->cost_pes_e);
		$sub_dolares5 = ($object->num_piezas_e * $object->cost_dol_e);
		$total = ($object->num_piezas_a + $object->num_piezas_b + $object->num_piezas_c + $object->num_piezas_d + $object->num_piezas_e);
		$sub_pesos = ($sub_pesos1 + $sub_pesos2 + $sub_pesos3 + $sub_pesos4 + $sub_pesos5);
		$sub_dolares = ($sub_dolares1 + $sub_dolares2 + $sub_dolares3 + $sub_dolares4 + $sub_dolares5);


how can i make a function in the class and every time that i need this calculation (or a better code of calculation) i don't have to copy all this code??? 

thank's ahead