sizeof() returns the
size of an array. (# of cells)
charsmax() is a macro for sizeof()-1.
string.inc
PHP Code:
#define charsmax(%1) (sizeof(%1)-1)
As fysiks said, you will almost always use charsmax() when dealing with strings since 1 array cell must be reserved for a null character. In both of your code blocks above it is correct to use charsmax().
When working with arrays and you need to access every cell in the array in a loop or w\e, you would use sizeof().
PHP Code:
new iArray[ 10 ]; //elements are accessed using index 0 through 9
//this loop will reach every element in the array from 0 to 9.
for ( new i = 0 ; i < sizeof( iArray ) ; i++ )
//equal to
for ( new i = 0 ; i < 10 ; i++ )
//if you used charsmax(), cell index 9 would never be reached.
for ( new i = 0 ; i < charsmax( iArray ) ; i++ )
//equal to
for ( new i = 0 ; i < 9 ; i++ )
__________________