yaml_parse() 函數可以解析 YAML 流。
用法
mixed yaml_parse( string $input [, int $pos = 0 [, int &$ndocs [, array $callbacks = null ]]] )
yaml_parse() 函數可以將 YAML 文檔流的全部或部分轉換為 PHP 變量。
yaml_parse() 函數可以返回在輸入中以適當的 PHP 類型編碼的值或失敗時返回的值。如果 pos 為 -1,則可以為流中找到的每個文檔返回一個包含一個條目的數組。
示例
<?php
$yaml = <<<EOD
---
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);
?>
相關用法
- PHP yaml_emit()用法及代碼示例
- PHP PHPUnit assertIsNotFloat()用法及代碼示例
- PHP disk_total_space()用法及代碼示例
- PHP ReflectionClass getTraitAliases()用法及代碼示例
- PHP hash_hmac()用法及代碼示例
- PHP String wordwrap()用法及代碼示例
- PHP SimpleXMLElement children()用法及代碼示例
- PHP is_file( )用法及代碼示例
- PHP ArrayIterator asort()用法及代碼示例
- PHP IntlCalendar getTimeZone()用法及代碼示例
- PHP SplPriorityQueue isCorrupted()用法及代碼示例
- PHP XMLReader::getParserProperty()用法及代碼示例
- PHP imagegif()用法及代碼示例
- PHP imageresolution()用法及代碼示例
- PHP SplFileInfo getPerms()用法及代碼示例
- PHP array_reverse()用法及代碼示例
注:本文由純淨天空篩選整理自 PHP - yaml_parse() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。