NdArray::shape

Tuple of array dimensions.

Description

array NdArray::shape

Return Values

A 1-dim array

Examples

Example #1: Get the NdArray shape

use SciPhp\NumPhp as np;

$m np::linspace(199)->reshape(33);

$shape np::ar($m->shape);

echo 
"m\n$m""shape=$shape\n";

The above example will output:

m
[[1  2  3]
 [4  5  6]
 [7  8  9]]
shape=[3  3]

Example #2: Reshape an NdArray

use SciPhp\NumPhp as np;

$m np::ar([1234]);

$m->shape = [22];

echo 
"m\n$m";

The above example will output:

m
[[1  2]
 [3  4]]

See Also