To declare a float array in PHP, you can use array literal notation or the array() function.
In this example,
$floatArray
with predefined values using array literal notation.<?php
$floatArray = [1.2, 3.4, 5.6];
print_r('Float Array:');
print_r($floatArray);
?>
Float Array:Array ( [0] => 1.2 [1] => 3.4 [2] => 5.6 )
In this example,
$emptyFloatArray
using the array() function without any elements.<?php
$emptyFloatArray = array();
print_r('Empty Float Array:');
print_r($emptyFloatArray);
?>
Empty Float Array:Array ( )
In this tutorial, we learned How to Declare a Float Array in PHP language with well detailed examples.