hugeness Posted January 19, 2010 Share Posted January 19, 2010 Hello... tearing my hair out trying to extract the contents of an array that looks a bit like this: a:2:{i:0;s:5:"Spec1";i:1;s:5:"Spec6";} an array being carried over as the variable $ts7 its being sent by a wonderfully useful jquery selection list, but i dont know how to get the actual variables out of it.. in this case Spec1 and Spec6. have tried variations along the lines of <?php if (preg_match("/"./"", $ts7, $ts7)) { echo "Match was found <br />"; echo $ts7[0]; } but to no avail.. any pointers gratefully received.. i'm rubbish at these but keen to improve, so any links to useful tutorials/sites also great would be! Quote Link to comment https://forums.phpfreaks.com/topic/189073-the-bits-of-an-array-surrounded-by-marks/ Share on other sites More sharing options...
cags Posted January 19, 2010 Share Posted January 19, 2010 Theoretically to match those values you'd use something more like... ' #"[^"]+"#' But I suspect there is a better method, whilst I don't recognise that format it seems very specific, it could be JSON or something similar. Quote Link to comment https://forums.phpfreaks.com/topic/189073-the-bits-of-an-array-surrounded-by-marks/#findComment-998321 Share on other sites More sharing options...
Daniel0 Posted January 19, 2010 Share Posted January 19, 2010 Use the unserialize function. Quote Link to comment https://forums.phpfreaks.com/topic/189073-the-bits-of-an-array-surrounded-by-marks/#findComment-998336 Share on other sites More sharing options...
hugeness Posted January 20, 2010 Author Share Posted January 20, 2010 Thank you both, will look further at the regex.. that looks amazing, for now the unserialize gets the array out into a useable form, jobs a good 'un! marvellous! [solved] Use the unserialize function. Quote Link to comment https://forums.phpfreaks.com/topic/189073-the-bits-of-an-array-surrounded-by-marks/#findComment-998522 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.