PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Table of Contents

PHP Arrays

Arrays allow us to assign multiple values into an array and store that into a variable.

First, we need to create a variable, and then we will store three items inside of an array, and we do this inside of ().

$cars = array('BMW', 'Audi', 'Mercedes');

The different items inside the array have to be separated by a ,.

If we try to echo out an array, it will give us an error because we can not echo out an array, but we can only echo out a specific index of our array.

Let's echo out the index of 1:

$cars = array('BMW', 'Audi', 'Mercedes');

echo $cars[1];

This will print out Audi. If you're wondering why it's printing out the second item instead of the first one, that is because arrays start off at 0 instead of 1.

So let's print out the first item (BMW) in our array:

<?php

$cars = array('BMW', 'Audi', 'Mercedes');

echo $cars[0];

?>

It's crucial that you remember:

Arrays start off at 0 instead of 1!

If you really do need to print out your array, you can use a function called print_r. This will print in a readable format your array.

$cars = array('BMW', 'Audi', 'Mercedes');

print_r($cars);
let checkoutBtns = document.getElementsByClassName("checkout"); for( var i=0; i < checkoutBtns.length; i++ ){ if(checkoutBtns[i].dataset.redirect){ redirectAfterPurchase = checkoutBtns[i].dataset.redirect; } checkoutBtns[i].addEventListener('click', openCheckout, false); } function openCheckout(e) { let checkoutButton = e.currentTarget; let productCheckout = parseInt('593446'); if(checkoutButton.dataset.product){ productCheckout = checkoutButton.dataset.product; } let couponCheckout = ''; if(checkoutButton.dataset.coupon){ couponCheckout = checkoutButton.dataset.coupon; } Paddle.Checkout.open({ product: productCheckout, email: '', successCallback: "checkoutComplete", coupon: couponCheckout, }); } let updateBtns = document.getElementsByClassName("update-account"); for( var i=0; i < updateBtns.length; i++ ){ updateBtns[i].addEventListener('click', updateAccount, false); } function updateAccount(){ Paddle.Checkout.open({ override: this.dataset.url, successCallback: "updateCancelComplete", }); } let cancelBtns = document.getElementsByClassName("cancel-account"); for( var i=0; i < cancelBtns.length; i++ ){ cancelBtns[i].addEventListener('click', cancelAccount, false); } function cancelAccount(){ Paddle.Checkout.open({ override: this.dataset.url, successCallback: "cancelComplete", }); } -->