Print Array function

The code below prints outs each array element, but it always says the array length is 1 even though its not. What am i doing wrong?

 
function printArray(){
        #here should check if it is an array and that an arg exits

        echo "Priting array"
        myarr="${@}"
        echo "Array length is ${#myarr[@]}"
        for element in ${myarr[@]} ; do
                echo $element
        done
}

 
printArray "${array[@]}"

Thanks

You created a scalar variable, not an array.

myarr=( "$@" )
echo "Array length is ${#myarr[@]}"
printf "%s\n" "${myarr[@]}"

Thanks, that worked great