I am wanting to break down a string in to different parts and because of the nature of the string I cant quite get my head around how I could go about doing this or if its possible.
Below is the string that I am trying to break up:
"'1,2,3,4','2,4,5,6,4',NULL, NULL,NULL ,'2,3,4,5', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL"
I would like it like:
'1,2,3,4',
'2,4,5,6,4',
NULL,
NULL,
'2,3,4,5'
I was thinking of dooing something like this:
$test = 'CALL sp_advert_search_load(\'1,3,4,5\',\'2,4,3\',NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)';
$test1 = explode( '(',$test);
$test1 = explode( ',',$test1[1]);
foreach ($test1 as $food) {
echo $food."<br />";
}
Then trying to build the array back into strings using the ' and a start and end point somehow.
json_decode, that's probably the best bet. Put brackets around it and sub'for".