如何用PHP解析这种文本格式?

时间:2015-03-17 10:22:02

标签: php parsing text-processing

如何用PHP解析这些数据?我不认识这种格式。字段名称似乎由[a-z]_组成。子字段应缩进2个空格。

---
field_name:
  sub_field: This is text content
  sub_field1: |-
    This is multiline text content. This is multiline text content. This is multiline text content.

    This is multiline text content.

    Thanks
  number_field: 2
  another_field: ''
  array_field: []
field_name1:
  sub_field_with_empty_value: 
  note: single line text field can have serveral lines
this is also 'note' field

...

1 个答案:

答案 0 :(得分:1)

这是YAML个文件。请参阅PHP YAML parsing reference