如何在CodeIgniter中设置文本格式 [英] How to format text in CodeIgniter

查看:130
本文介绍了如何在CodeIgniter中设置文本格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在电子邮件中传送阵列。我使用函数

Im trying to send an array in an email. I use the function

$ this-> email-> message(print_r($ array2,true));

当我使用这个,数组在电子邮件中通过,但它显示在一行。是否可以使用像pre和/ pre标签来格式化?我尝试在CI中使用排版助手,

When i use this, the array come through in the email, but its displayed in a single line. Is it possible to use something like "pre and /pre" tags to format it? I tried using the typography helper in CI,

$this->load->helper('typography');
$array2 = auto_typography($array);

但它似乎不工作。有关如何处理这个问题的任何想法吗?

but it doesn't seem to work. Any ideas on how to go about this?

感谢,

Chris。

推荐答案

这个工程。我尝试了。

$message = '<pre>'.print_r($array2, true).'</pre>';
$this->email->message($message);

但是你需要先做这个。在您的电子邮件配置中:

But you need to do this first. On your email config:

$config = Array(
            'protocol' => 'smtp',
            'mailtype'  => 'html',
            'charset'   => 'iso-8859-1',
            'newline'  => '<br/>',
            'wordwrap'  => TRUE
);

$this->load->library('email', $config); 

$ config ['mailtype']是负责预格式化文本的文件。

The $config['mailtype'] is the one responsible for the preformatted text.

这篇关于如何在CodeIgniter中设置文本格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆