$urls = array_slice($urls, 0, 1);

How about this?  Input is defined as an array so it can't be null or a string and array_slice returns an empty array if the input array is empty.