Jump to content

select if in a long text char line


Monkuar

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.