PDA

View Full Version : php line breaks ?


paul41598
01-06-2007, 10:27 PM
Ok I'm having a problem with line breaks...

I basically have this code

$msgfield = @explode("\n", $vbulletin->options['on_usergroupchange_text']);

with the below text box. Im trying to be able to type into it but use line breaks and have them parse correctly in a PM. Can anyone say for sure what I'm doing wrong? IT doesnt parse correctly at all. In fact, it doesnt parse, I get nothing unless I move both Hello's next to one another then its fine.

I thought \n is the right character.. hmmm

Guest190829
01-06-2007, 11:13 PM
Try the nl2br() (http://www.php.net/nl2br) function

paul41598
01-06-2007, 11:44 PM
dam, no go either


$msgfield = nl2br($vbulletin->options['on_usergroupchange_text']);



this is my whole chunk of code:


$msgfield = nl2br($vbulletin->options['on_usergroupchange_text']);
$msg = $msgfield[@array_rand($msgfield)];
$pmbodyfield = @str_replace("{username}", $vbulletin->userinfo['username'], $msg);

$pmdm =& datamanager_init('PM', $this->registry, ERRTYPE_SILENT);
$pmdm->set('fromuserid', $vbulletin->options['on_usergroupchange_fromuserid']);
$pmdm->set('fromusername', $vbulletin->options['on_usergroupchange_fromusername']);
eval(fetch_email_phrases('usergroupschanged', $this->fetch_field('languageid')));
$pmdm->set('title', $vbulletin->options['on_usergroupchange_subject']);
$pmdm->set('message', $pmbodyfield);
$botperms = array('adminpermissions' => 2);
$pmdm->set_recipients($this->fetch_field('username'), $botperms); // Ignore PM-Box full
$pmdm->set('dateline', TIMENOW);
$pmdm->save();