yaml parse file php,PHP yaml_parse(),yaml_parse函数 Parse a YAML stream - phpStudy

Example #1 yaml_parse() example

$yaml= <<

invoice: 34843

date: "2001-01-23"

bill-to: &id001

given: Chris

family: Dumars

address:

lines: |-

458 Walkman Dr.

Suite #292

city: Royal Oak

state: MI

postal: 48046

ship-to: *id001

product:

- sku: BL394D

quantity: 4

description: Basketball

price: 450

- sku: BL4438H

quantity: 1

description: Super Hoop

price: 2392

tax: 251.420000

total: 4443.520000

comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.

...EOD;$parsed=yaml_parse($yaml);var_dump($parsed);?>

以上例程的输出类似于:

array(8) {

["invoice"]=>

int(34843)

["date"]=>

string(10) "2001-01-23"

["bill-to"]=>

&array(3) {

["given"]=>

string(5) "Chris"

["family"]=>

string(6) "Dumars"

["address"]=>

array(4) {

["lines"]=>

string(34) "458 Walkman Dr.

Suite #292"

["city"]=>

string(9) "Royal Oak"

["state"]=>

string(2) "MI"

["postal"]=>

int(48046)

}

}

["ship-to"]=>

&array(3) {

["given"]=>

string(5) "Chris"

["family"]=>

string(6) "Dumars"

["address"]=>

array(4) {

["lines"]=>

string(34) "458 Walkman Dr.

Suite #292"

["city"]=>

string(9) "Royal Oak"

["state"]=>

string(2) "MI"

["postal"]=>

int(48046)

}

}

["product"]=>

array(2) {

[0]=>

array(4) {

["sku"]=>

string(6) "BL394D"

["quantity"]=>

int(4)

["description"]=>

string(10) "Basketball"

["price"]=>

int(450)

}

[1]=>

array(4) {

["sku"]=>

string(7) "BL4438H"

["quantity"]=>

int(1)

["description"]=>

string(10) "Super Hoop"

["price"]=>

int(2392)

}

}

["tax"]=>

float(251.42)

["total"]=>

float(4443.52)

["comments"]=>

string(68) "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338."

}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值