Php 如何打印所选阵列?
我使用Php 如何打印所选阵列?,php,Php,我使用print\r($jcart)来获得上面的结果。 我只想打印出[qtys]数组。我尝试了print\r($qtys)但它不工作。必须引用数组元素。因此,您始终需要指向$jcart,然后从那里引用。正如谢尔盖所指出的,你有一个目标 Jcart对象 因此,必须引用对象的元素,而不是数组 Jcart Object( [config] => Array ( [jcartPath] => jcart/ [checko
print\r($jcart)
来获得上面的结果。
我只想打印出
[qtys]
数组。我尝试了print\r($qtys)代码>但它不工作。必须引用数组元素。因此,您始终需要指向$jcart
,然后从那里引用。正如谢尔盖所指出的,你有一个目标
Jcart对象
因此,必须引用对象的元素,而不是数组
Jcart Object(
[config] => Array
(
[jcartPath] => jcart/
[checkoutPath] => checkout.php
[item] => Array
(
[id] => my-item-id
[name] => my-item-name
[price] => my-item-price
[qty] => my-item-qty
[url] => my-item-url
[add] => my-add-button
)
[paypal] => Array
(
[id] => seller_1282188508_biz@conceptlogic.com
[https] => 1
[sandbox] =>
[returnUrl] =>
[notifyUrl] =>
)
[currencyCode] => USD
[csrfToken] =>
[text] => Array
(
[cartTitle] => Shopping Cart
[singleItem] => Item
[multipleItems] => Items
[subtotal] => Subtotal
[update] => update
[checkout] => checkout
[checkoutPaypal] => Checkout with PayPal
[removeLink] => remove
[emptyButton] => empty
[emptyMessage] => Your cart is empty!
[itemAdded] => Item added!
[priceError] => Invalid price format!
[quantityError] => Item quantities must be whole numbers!
[checkoutError] => Your order could not be processed!
)
[button] => Array
(
[checkout] =>
[paypal] =>
[update] =>
[empty] =>
)
[tooltip] => 1
[decimalQtys] =>
[decimalPlaces] => 1
[priceFormat] => Array
(
[decimals] => 2
[dec_point] => .
[thousands_sep] => ,
)
)
[items] => Array
(
[0] => 3
[1] => poslaju
)
[names] => Array
(
[3] => Hockey Stick
[poslaju] => Pos Laju
)
[prices] => Array
(
[3] => 33.25
[poslaju] => 6.00
)
[qtys] => Array
(
[3] => 1
[poslaju] => 3
)
[urls] => Array
(
[3] => http://bing.com
[poslaju] =>
)
[subtotal] => 51.25
[itemCount] => 4
)
使用参考键选择所需的特定元素
print_r($jcart->qtys);
echo';打印($jcart->qtys);
标记只是为了以更好的格式查看数组而添加的您必须将true
添加到print\u r
以这样的方式连接它似乎$jcart
是jcart
的实例,所以可能引用应该是$jcart->qtys
?@SergeyChizhik,的确如此。我第一次读的时候就错过了。
echo '<pre>'; print_r($jcart->qtys);