Reputation: 37
I have two arrays. I want only array "one" to run if the variable "purchase" is true. If that variable is false then only run array "two"
I'm a novice at PHP so forgive me if the terminology is wrong. I assume it would involve an if/else statement
$purchase = "----";
// This is array "one"
$charge = \Stripe\Charge::create(array(
"customer" => $customer->id,
"description" => "Single Purchase")
));
// This is array "two"
$subscription = \Stripe\Subscription::create(array(
"customer" => $customer->id,
"plan" => $_POST['subscription'],
"coupon" => $_POST['coupon'],
"quantity" => $_POST['quantity'],
"description" => "Subscription")
));
Upvotes: 0
Views: 26
Reputation: 474
if($purchase){
// This is array "one"
$charge = \Stripe\Charge::create(array(
"customer" => $customer->id,
"description" => "Single Purchase")
));
} else{
// This is array "two"
$subscription = \Stripe\Subscription::create(array(
"customer" => $customer->id,
"plan" => $_POST['subscription'],
"coupon" => $_POST['coupon'],
"quantity" => $_POST['quantity'],
"description" => "Subscription")
));
}
If the $purchase
variable is true then the array one will run else array two block will run
Upvotes: 1