如何打印 paypal 返回数组

发布于 2024-12-17 17:09:05 字数 857 浏览 0 评论 0原文

我正在使用 Martin Maly 的 Paypal Library,一切正常。我无法做到的是我在返回页面中得到类似的内容;

   Array
(
    [TOKEN] => EC-49D73912N5410881H
    [TIMESTAMP] => 2011-11-24T10:59:46Z
    [CORRELATIONID] => 328dc8f80aac
    [ACK] => Success
    [VERSION] => 52.0
    [BUILD] => 2271164
    [EMAIL] => [email protected]
    [PAYERID] => QZNN94QVUSL88
    [PAYERSTATUS] => verified
    [FIRSTNAME] => Test
    [LASTNAME] => User
    [COUNTRYCODE] => FR
    [CUSTOM] => 20|EUR|
)

我希望所有这些数据都单独打印,例如;

echo $array['EMAIL'];

这是我第一次使用数组,我不知道如何处理它? 如果这里有人帮助我,我会非常高兴。 谢谢。

I am using Martin Maly's Paypal Library and everything works properly.The thing I could not manage to do is I get something like this in the returning page;

   Array
(
    [TOKEN] => EC-49D73912N5410881H
    [TIMESTAMP] => 2011-11-24T10:59:46Z
    [CORRELATIONID] => 328dc8f80aac
    [ACK] => Success
    [VERSION] => 52.0
    [BUILD] => 2271164
    [EMAIL] => [email protected]
    [PAYERID] => QZNN94QVUSL88
    [PAYERSTATUS] => verified
    [FIRSTNAME] => Test
    [LASTNAME] => User
    [COUNTRYCODE] => FR
    [CUSTOM] => 20|EUR|
)

And I want all these data to be printed seperately such as;

echo $array['EMAIL'];

This is the first time I work with arrays and I have no idea how to deal with it?
I would be very glad if anyone out here help me.
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橘味果▽酱 2024-12-24 17:09:05

您可以这样做:

print_r($array);

或者如果您希望它更具可读性:

foreach ($array as $key => $value) {
    echo "$key: $value\n";
}

或者如果您想输出一些数组值但不输出其他值,则可以这样做:

$output_these_keys = array('FIRSTNAME', 'LASTNAME', 'CUSTOM');
foreach ($array as $key => $value) {
    if (in_array($key, $output_these_keys)) echo "$key: $value\n";
}

You can either do:

print_r($array);

or if you want it more readable:

foreach ($array as $key => $value) {
    echo "$key: $value\n";
}

or this if you want to output some array values but not others:

$output_these_keys = array('FIRSTNAME', 'LASTNAME', 'CUSTOM');
foreach ($array as $key => $value) {
    if (in_array($key, $output_these_keys)) echo "$key: $value\n";
}
情场扛把子 2024-12-24 17:09:05

您想分别访问和打印数组键和数组值吗?给你:

foreach($array as $key => $value) {
  echo $key . ": " . $value;
}

此外,如果您想删除键并使用从 0 开始的索引数组(即能够使用索引访问数组),请使用 array_values($array); ,这将返回索引数组

并且不要害怕真正有用的官方文档

Do you want to access and print array keys and array values separately? Here you go:

foreach($array as $key => $value) {
  echo $key . ": " . $value;
}

Also, if you want to drop the keys and instead have indexed array starting from 0 (that is, being able to access array with indexes), use array_values($array); which will return indexed array

And don't be afraid of really helpful official documentation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文