支持文件类型 (Strings)

.PHP - 数组 (Strings)

文本由 Phrase Language AI 从英语机器翻译而得。

文件扩展名

.php

API 扩展

php_array

导入

导出

复数形式支持

描述支持

数组是一个有序的列表或项目集合。数组的项目基本上可以是 PHP 中的任何类型:数字、字符串、对象、另一个数组等。我们经常在区域消息数组中使用 Strings 作为值。 PHP 数组主要有两种类型:

  • 索引数组 — 这些数组是隐式排序的,例如 ['red', 'green', 'blue']

  • 关联数组 — 这些数组包含键(可以是整数或字符串)和关联值的对,例如 ['first_name' => 'Adam', 'last_name' => 'McMan', 'age' => 22]

数组元素的值可以在初始化期间或使用数组本身的变量名进行设置。

<?php

// 初始化期间

$my_array = ['foo' => 'bar'];

// 使用变量名 

$my_second_array['key'] = 'value'

这种设置值的方法可以混合搭配使用。

使用数组工作

从命令行提取时,消息文件将以以下格式发送,并使用关联的命名数组。

<?php

$lang['键'] = '已翻译的消息';

$lang['another_键'] = '另一条已翻译的消息';

确保应用程序已设置好以使用这种格式工作。不要在消息文件中返回匿名数组,并为消息数组使用名称 $lang

代码示例

<?php

$lang['boolean_key'] = '--- true
';
$lang['empty_string_translation'] = '';
$lang['key_with_description'] = '看看这个!This key has a description!(至少在某些格式中)“;
$lang['key_with_line-break'] = '此翻译包含
换行符。';
$lang['nested.deeply.key'] = '哇,此键嵌套得更深。';
$lang['nested.key'] = '此键嵌套在命名空间内。';
$lang['null_translation'] = '';
$lang['sample_collection'] = '---
- first item
- second item
- third item
';
$lang['simple_key'] = '只是一个带有简单消息的简单键。';
$lang['unverified_key'] = '此翻译尚未经过未验证,正在等待验证。(在某些格式中,我们也会导出此状态)“;
这篇文章有帮助吗?

Sorry about that! In what way was it not helpful?

The article didn’t address my problem.
I couldn’t understand the article.
The feature doesn’t do what I need.
Other reason.

Note that feedback is provided anonymously so we aren't able to reply to questions.
If you'd like to ask a question, submit a request to our Support team.
Thank you for your feedback.