Photoacoustic imaging with optical resolution usually requires a single-pixel raster scan. An alternative approach based on illumination with patterns obtained from a Hadamard matrix, measurement of the generated ultrasound wave with a single detector, followed by a reconstruction known from computational ghost imaging is demonstrated here. Since many pixels on the object are illuminated at the same time, thereby contributing to the recorded signal, this approach gives a better contrast-to-noise ratio compared to the raster scan, as demonstrated in a phantom experiment. Furthermore, exploiting the temporal information for depth-resolved imaging is possible. The proposed method will be beneficial in situations where the radiant exposure of a sample is limited due to either safety precautions or the properties of the available light source.