本文整理汇总了PHP中Receipt::json_encode方法的典型用法代码示例。如果您正苦于以下问题:PHP Receipt::json_encode方法的具体用法?PHP Receipt::json_encode怎么用?PHP Receipt::json_encode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Receipt
的用法示例。
在下文中一共展示了Receipt::json_encode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_receipt
public function add_receipt($receipt_data)
{
//new receipt
$receipt = new Receipt();
// get data
$receipt->get_data_from_array($receipt_data);
TEST($receipt->json_encode(false));
//compute the sequence of sql to add this receipt to db
$comma_seperated_list = $receipt->get_seperated_list();
TEST($comma_seperated_list);
//mysqli_query($this->db, "CALL test('$comma_seperated_list');");
}
示例2: list_import_product_to_json_data
public function list_import_product_to_json_data($data)
{
//new a new receipt
//basically, a Reiceipt is a list of product...
$receipt = new Receipt();
foreach ($data as $value) {
//new Product
$product = new ImportProduct($value['Import_Price']);
// add attribute to it
$product->add_attribute($value['Name'], new Unit($value['UnitName'], $value['Price']), $value['Id'], $value['ProductId']);
//add the product to the receipt
$receipt->add($product);
}
// return the receipt in json format
return $receipt->json_encode();
}
示例3: push_new_product_data_to_server
function push_new_product_data_to_server($array)
{
if (sizeof($array) == 0) {
return;
}
$receipt = new Receipt();
foreach ($array as $key => $product) {
if (isset($product['name'])) {
$import_product = new ImportProduct($product['bought']);
$import_product->add_attribute($product['name'], new Unit($product['unit_name'], $product['sale']));
$receipt->add($import_product);
}
}
echo $receipt->json_encode(true);
$manage = new Management();
$manage->push_new_product_data_to_server($receipt);
}