I'm trying to get the list of all stripe subscribers on my PHP page.
I have managed to get the details of 1 subscriber from the array that's returned from stripe API so far.
But when I try to get the details of 2 or 3 etc subscribers, I get nothing.
I know I will need to use a loop or for each to achieve this but I can't figure out how.
This is my current code to get the details of 1 subscriber:
$data = \Stripe\Subscription::all(['limit' => 1]);
$sub_id = $data->data[0]->id;
echo $sub_id;
Now I need to get the details of more than 1 subscriber so I tried this which didn't work and doesn't return anything (no errors either):
$data = \Stripe\Subscription::all(['limit' => 2]);
foreach ($data as $k => $v) {
echo $data->data[0]->id;
}
could someone please advise on this issue?
You probably need to loop $data->data
as it is an array of objects and then access the id
property of each object:
foreach ($data->data as $v) {
echo $v->id;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.