Monkuar Posted January 7, 2012 Share Posted January 7, 2012 Code: PostInfo,color-main,Newman,not-collapsed;Friends,color-main2,Top Friends,not-collapsed||Twitter,color-main2,Twitter,not-collapsed;Signature,color-main2,Signature,not-collapsed;AboutMe,color-transparent,About Me,not-collapsed Now I want make a function like if PostInfo = "not-collapsed" = do this/etc, So simply, how do I extract some content out of this and then use each thing to equal to if it's 'not-collapsed' or 'collapsed' ? Very hard but i think possible? ty Link to comment https://forums.phpfreaks.com/topic/254535-select-if-in-a-long-text-char-line/ Share on other sites More sharing options...
Pikachu2000 Posted January 7, 2012 Share Posted January 7, 2012 If it was in a completely consistent format, you might have a chance, but as it is right now, I don't see how you could effectively do it. Link to comment https://forums.phpfreaks.com/topic/254535-select-if-in-a-long-text-char-line/#findComment-1305295 Share on other sites More sharing options...
Monkuar Posted January 8, 2012 Author Share Posted January 8, 2012 If it was in a completely consistent format, you might have a chance, but as it is right now, I don't see how you could effectively do it. well im trying to spit them out by explode with , but theres going to be to many if's Link to comment https://forums.phpfreaks.com/topic/254535-select-if-in-a-long-text-char-line/#findComment-1305441 Share on other sites More sharing options...
ngreenwood6 Posted January 8, 2012 Share Posted January 8, 2012 Maybe you can take a look at this to see if it will work for you or if there is something you can build off of it : //the original string $string = 'PostInfo,color-main,Newman,not-collapsed;Friends,color-main2,Top Friends,not-collapsed||Twitter,color-main2,Twitter,not-collapsed;Signature,color-main2,Signature,not-collapsed;AboutMe,color-transparent,About Me,not-collapsed'; //could be wrong but seems like this should just be a semi-colon $string = str_replace('||',';',$string); //explode them by the ; as it seems that is the separator of the content $ex_string = explode(';',$string); //count them (faster than doing it in the loop) $ex_count = count($ex_string); //loop through each of the sets for($i=0;$i<$ex_count;$i++){ //now you can explode them on the comma to get there data $ex_string[$i] = explode(',',$ex_string[$i]); //you can either check the data here if($ex_string[$i][0] == 'PostInfo' && $ex_string[$i][3] == 'not-collapsed'){ //it is not collapsed so do something } } //print it out so you can see the data print_r($ex_string); Link to comment https://forums.phpfreaks.com/topic/254535-select-if-in-a-long-text-char-line/#findComment-1305443 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.