支持文件类型 (Strings)

.PHP - 数组 (字符串)

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

文件扩展名

.php

API 扩展

php_array

导入

导出

复数形式支持

描述支持

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

  • 索引数组 — 这些数组是隐式有序的,例如 ['红色', '绿色', '蓝色']

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

数组元素的值可以在初始化时设置,也可以使用数组本身的变量名设置。

<?php

// 在初始化时

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

// 使用变量名 

$my_second_array['key'] = 'value'

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

处理数组

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

<?php

$lang['key'] = '翻译后的消息';

$lang['another_key'] = '另一个翻译后的消息';

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

代码示例

<?php

$lang['boolean_key'] = '--- true
';
$lang['empty_string_translation'] = '';
$lang['key_with_description'] = '看看这个!这个键有一个描述!(至少在某些格式中)';
$lang['key_with_line-break'] = '这个翻译包含
一个换行。';
$lang['nested.deeply.key'] = '哇,这个键嵌套得更深。';
$lang['nested.key'] = '这个键嵌套在一个命名空间中。';
$lang['null_translation'] = '';
$lang['sample_collection'] = '---
- 第一个条目
- 第二个条目
- 第三个条目
';
$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.