SeanHarding Posted November 21, 2011 Share Posted November 21, 2011 Is there a way of detecting how big my unserialize() array is before I store it? TEXT will hold 65K and LONGTEXT will hold 4GB. If the string is too long I would like to reply with a message. Quote Link to comment Share on other sites More sharing options...
requinix Posted November 21, 2011 Share Posted November 21, 2011 Any reason you're serializing() data? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted November 21, 2011 Share Posted November 21, 2011 This should work: mb_strlen Quote Link to comment Share on other sites More sharing options...
SeanHarding Posted November 22, 2011 Author Share Posted November 22, 2011 Sorry for the long reply. I will be serializing my multidimensional array as the arrays are user generated. I would prefer to create and store arrays rather than create numerous tables in MySQL. With mb_strlen() does 1 character = 1byte? I'm assuming I'd use mb_strlen($string, '8 bit'); Quote Link to comment Share on other sites More sharing options...
fenway Posted November 23, 2011 Share Posted November 23, 2011 This sounds like a follow-up to you other question. Quote Link to comment Share on other sites More sharing options...
requinix Posted November 23, 2011 Share Posted November 23, 2011 With mb_strlen() does 1 character = 1byte? I'm assuming I'd use mb_strlen($string, '8 bit'); 1. The "mb" means "multibyte". Because not all characters are one byte long. mb_strlen() counts characters while strlen() counts bytes. 2. No. Use the same character encoding that your *TEXT column uses. Quote Link to comment Share on other sites More sharing options...
fenway Posted November 23, 2011 Share Posted November 23, 2011 I would prefer to create and store arrays rather than create numerous tables in MySQL. That sounds like a plan doomed to fail. Quote Link to comment Share on other sites More sharing options...
SeanHarding Posted November 24, 2011 Author Share Posted November 24, 2011 Its certainly an interesting project. I'm doing allot of math during the project and instead of creating multiple requests I'll be manipulating the array and storing it later. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.