Pentiums Posted October 4, 2009 Report Share Posted October 4, 2009 Gribu pie vēstuļu sūtīšanas temata pievienot kautko līdzīgu kā draugiem.lv un citos portālos, ja tematu nenomaina, tad temata priekšā parādās [RE:1]blablabla, [RE:2]blablabla, [RE:3]blablabla ,[RE:4]blablabla... kā īsti ir, būs ar explode jāstrādā? Varat parādīt kādu piemēru? Quote Link to comment Share on other sites More sharing options...
Pentiums Posted October 4, 2009 Author Report Share Posted October 4, 2009 (edited) $str = '[RE:1]Čau kā iet?'; $str = explode('[RE:', $str); $str = explode(']', $str[1]); echo $str[0]; Kautkā tā? Edited October 4, 2009 by Pentiums Quote Link to comment Share on other sites More sharing options...
marcis Posted October 4, 2009 Report Share Posted October 4, 2009 Kaut kā šitā (testēts nav) $str = '[RE:1]Čau kā iet?'; $matches = array(); if(preg_match("/^\[Re\:(\d+)\](.*)$/", $str, $matches)){ $str = '[Re:'.++$matches[1].']'.$matches[2]; }else{ $str = '[Re:1]'.$str; } Quote Link to comment Share on other sites More sharing options...
Pentiums Posted October 4, 2009 Author Report Share Posted October 4, 2009 if(strstr($data['virsraksts'], '[RE:')) { $str = $data['virsraksts']; $str2 = explode(']', $str); $str = explode('[RE:', $str); $str = explode(']', $str[1]); $str = $str[0]; $str++; $data['virsraksts'] = '[RE:'.$str.']'.$str2[1]; } else { $data['virsraksts'] = '[RE:1]'.$data['virsraksts']; } Man šitāds. Pamēģināšu tavu :) Quote Link to comment Share on other sites More sharing options...
Pentiums Posted October 4, 2009 Author Report Share Posted October 4, 2009 Strādā! :) 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.