BriCode Thoughts from Brian Holt

30Aug/110

PHP sizeof() or count() not working on my string to return the length!

Quick PHP tip here. I spent a half hour trying to figure this out and I figure someone else must be seeing something similar. sizeof() and count() only work (as you would expect them to work, anyway) on arrays. If you use it on a string, it will return 1 because it views a string as an array of one string in that context. The function you are actually searching for is strlen() like in C. Hope that saves someone some time.

Comments (0) Trackbacks (0)

No comments yet.


Comments are closed.

No trackbacks yet.