NDArray::array
public static function array(array|float|int $array): NDArray;
Creates a new NDArray from a PHP array. It is the equivalent of new NDArray($array);
Parameters
$array
Type
array[long|double,]
- The PHP array to be converted to a NDArray
Return
Type - NDArray
- A single-precision (float32) NDArray with the same shape and values of
$array
Notes
note
Every floating point in PHP is a double precision (float64) so some precision may be lost during conversion.
Examples
- Example 1
use \NDArray as nd;
$a = nd::array([[1, 2], [3, 4]]);
print_r($a);
[[1, 2],
[3, 4]]