本文整理汇总了PHP中wordwrap函数的典型用法代码示例。如果您正苦于以下问题:PHP wordwrap函数的具体用法?PHP wordwrap怎么用?PHP wordwrap使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wordwrap函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
public function send($to, $subject, $message, $from = NULL, $attachments = NULL)
{
if ($attachments != NULL) {
throw new ServiceException("INVALID_CONFIGURATION", "Default mailer does not support sending attachments");
}
if (Logging::isDebug()) {
Logging::logDebug("Sending mail to [" . Util::array2str($to) . "]: [" . $message . "]");
}
if (!$this->enabled) {
return;
}
$isHtml = stripos($message, "<html>") !== FALSE;
$f = $from != NULL ? $from : $this->env->settings()->setting("mail_notification_from");
$validRecipients = $this->getValidRecipients($to);
if (count($validRecipients) === 0) {
Logging::logDebug("No valid recipient email addresses, no mail sent");
return;
}
$toAddress = '';
$headers = $isHtml ? 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=utf-8' . "\r\n" : 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/plain; charset=utf-8' . "\r\n";
$headers .= 'From:' . $f;
if (count($validRecipients) == 1) {
$toAddress = $this->getRecipientString($validRecipients[0]);
} else {
$headers .= PHP_EOL . $this->getBccHeaders($validRecipients);
}
mail($toAddress, $subject, $isHtml ? $message : str_replace("\n", "\r\n", wordwrap($message)), $headers);
}
示例2: send_notification_email
function send_notification_email($to_email, $subject, $message, $reply_to = '', $reply_to_name = '', $plain_text = true, $attachments = array())
{
$content_type = $plain_text ? 'text/plain' : 'text/html';
$reply_to_name = $reply_to_name == '' ? wp_specialchars_decode(get_option('blogname'), ENT_QUOTES) : $reply_to_name;
//senders name
$reply_to = ($reply_to == '' or $reply_to == '[admin_email]') ? get_option('admin_email') : $reply_to;
//senders e-mail address
if ($to_email == '[admin_email]') {
$to_email = get_option('admin_email');
}
$recipient = $to_email;
//recipient
$header = "From: \"{$reply_to_name}\" <{$reply_to}>\r\n Reply-To: \"{$reply_to_name}\" <{$reply_to}>\r\n Content-Type: {$content_type}; charset=\"" . get_option('blog_charset') . "\"\r\n";
//optional headerfields
$subject = wp_specialchars_decode(strip_tags(stripslashes($subject)), ENT_QUOTES);
$message = do_shortcode($message);
$message = wordwrap(stripslashes($message), 70, "\r\n");
//in case any lines are longer than 70 chars
if ($plain_text) {
$message = wp_specialchars_decode(strip_tags($message), ENT_QUOTES);
}
$header = apply_filters('frm_email_header', $header, compact('to_email', 'subject'));
if (!wp_mail($recipient, $subject, $message, $header, $attachments)) {
$header = "From: \"{$reply_to_name}\" <{$reply_to}>\r\n";
mail($recipient, $subject, $message, $header);
}
do_action('frm_notification', $recipient, $subject, $message);
}
示例3: write
public static function write($image, $fontfile, $x, $y, $text, $color, $maxwidth, $size = 11, $spacingx = 2, $spacingy = 2, $mx = 1, $my = 1, $angle = 0)
{
if (!Common::isFile($fontfile)) {
echo GWF_HTML::err('ERR_FILE_NOT_FOUND', array(htmlspecialchars($fontfile)));
return false;
}
$dim = GWF_GDText::getFontSize($fontfile, $size, $angle);
$fontwidth = $dim->w;
$fontheight = $dim->h;
if ($maxwidth != NULL) {
// die(''.$maxwidth);
$maxcharsperline = floor($maxwidth / $fontwidth);
$text = wordwrap($text, $maxcharsperline, "\n", 1);
// die($text);
}
// die(var_dump($color));
$lines = explode("\n", $text);
$x += $mx;
$y += $my;
foreach ($lines as $line) {
$y += $fontheight + $spacingy;
imagettftext($image, $size, $angle, $x, $y, $color, $fontfile, $line);
}
return true;
}
示例4: printevent
function printevent($record, $prettydate)
{
print "\n" . strtoupper($record["title"]) . "\n";
$again = repeatfirstinstance($record, $prettydate);
if ($again) {
print "See {$again[date]} for details\n";
} else {
print hmmpm($record["eventtime"]) . "\n";
if ($record["locname"]) {
print "{$record[locname]}, {$record[address]}\n";
} else {
print "{$record[address]}\n";
}
print wordwrap($record["printdescr"], 68) . "\n";
if (!$record["hideemail"]) {
$email = preg_replace("/@/", " at ", $record["email"]);
$email = preg_replace("/\\./", " dot ", $email);
if ($record["weburl"] != "") {
print "{$email}, {$record[weburl]}\n";
} else {
print "{$email}\n";
}
} else {
if ($record["weburl"] != "") {
print "{$record[weburl]}\n";
}
}
}
}
示例5: block
/**
* Formats a message as a block of text.
*
* @param string|array $messages The message to write in the block
* @param string|null $type The block type (added in [] on first line)
* @param string|null $style The style to apply to the whole block
* @param string $prefix The prefix for the block
* @param bool $padding Whether to add vertical padding
*/
public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
{
$this->autoPrependBlock();
$messages = is_array($messages) ? array_values($messages) : array($messages);
$lines = array();
// add type
if (null !== $type) {
$messages[0] = sprintf('[%s] %s', $type, $messages[0]);
}
// wrap and add newlines for each element
foreach ($messages as $key => $message) {
$message = OutputFormatter::escape($message);
$lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - Helper::strlen($prefix), PHP_EOL, true)));
if (count($messages) > 1 && $key < count($messages) - 1) {
$lines[] = '';
}
}
if ($padding && $this->isDecorated()) {
array_unshift($lines, '');
$lines[] = '';
}
foreach ($lines as &$line) {
$line = sprintf('%s%s', $prefix, $line);
$line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line));
if ($style) {
$line = sprintf('<%s>%s</>', $style, $line);
}
}
$this->writeln($lines);
$this->newLine();
}
示例6: dumpSql
/**
* Returns syntax highlighted SQL command.
* @param string
* @return string
*/
public static function dumpSql($sql)
{
static $keywords1 = 'SELECT|(?:ON\\s+DUPLICATE\\s+KEY)?UPDATE|INSERT(?:\\s+INTO)?|REPLACE(?:\\s+INTO)?|DELETE|CALL|UNION|FROM|WHERE|HAVING|GROUP\\s+BY|ORDER\\s+BY|LIMIT|OFFSET|SET|VALUES|LEFT\\s+JOIN|INNER\\s+JOIN|TRUNCATE';
static $keywords2 = 'ALL|DISTINCT|DISTINCTROW|IGNORE|AS|USING|ON|AND|OR|IN|IS|NOT|NULL|LIKE|RLIKE|REGEXP|TRUE|FALSE';
// insert new lines
$sql = " {$sql} ";
$sql = preg_replace("#(?<=[\\s,(])({$keywords1})(?=[\\s,)])#i", "\n\$1", $sql);
// reduce spaces
$sql = preg_replace('#[ \\t]{2,}#', " ", $sql);
$sql = wordwrap($sql, 100);
$sql = preg_replace("#([ \t]*\r?\n){2,}#", "\n", $sql);
// syntax highlight
$sql = htmlSpecialChars($sql);
$sql = preg_replace_callback("#(/\\*.+?\\*/)|(\\*\\*.+?\\*\\*)|(?<=[\\s,(])({$keywords1})(?=[\\s,)])|(?<=[\\s,(=])({$keywords2})(?=[\\s,)=])#is", function ($matches) {
if (!empty($matches[1])) {
// comment
return '<em style="color:gray">' . $matches[1] . '</em>';
}
if (!empty($matches[2])) {
// error
return '<strong style="color:red">' . $matches[2] . '</strong>';
}
if (!empty($matches[3])) {
// most important keywords
return '<strong style="color:blue">' . $matches[3] . '</strong>';
}
if (!empty($matches[4])) {
// other keywords
return '<strong style="color:green">' . $matches[4] . '</strong>';
}
}, $sql);
return '<pre class="dump">' . trim($sql) . "</pre>\n";
}
示例7: combine
/**
* Create a cache file from the given list of files and return the cache file name
* @name combine
* @type method
* @access public
* @param array file list
* @return string cache file name
*/
public function combine($fileList)
{
if (count($fileList) > 0) {
$cacheFile = '';
$alphabet = array_map('chr', array_merge(range(48, 57), range(97, 122), range(65, 90)));
// a lot is going on on this line; first we take the md5 checksums of the files in the list, then this goes into a json blob, which is m5'd on its own and then wordwrapped at every 3rd character and lastly, the result gets exploded on the wordwrap added newlines. Leaving us with a 11 item array.
$checksum = explode(PHP_EOL, wordwrap(md5(json_encode(array_map('md5_file', $fileList))), 3, PHP_EOL, true));
while (count($checksum)) {
$cacheFile .= $alphabet[hexdec(array_shift($checksum)) % count($alphabet)];
}
$cacheFile = $this->_cachePath . '/' . $cacheFile . '.' . pathinfo($fileList[0], PATHINFO_EXTENSION);
// if the cache file exists, we gently push the modification time to now (this should make removing old obselete files easier to find)
if (realpath($cacheFile) && touch($cacheFile)) {
return basename($cacheFile);
}
// as no cache file was found (or we couldn't push the modification time), we need to generate it
$fp = fopen($cacheFile, 'w+');
if ($fp) {
foreach ($fileList as $file) {
$source = trim(file_get_contents($file)) . PHP_EOL;
if (substr($file, 0, strlen($this->_cachePath)) == $this->_cachePath) {
$source = '/*' . basename($file) . '*/' . $source;
}
fputs($fp, $source);
}
return basename($cacheFile);
}
}
return false;
}
示例8: addItem
/**
* splits item into new lines if necessary
* @param string $item
* @return CalendarStream
*/
public function addItem($item)
{
$line_breaks = array("\r\n", "\n", "\r");
$item = str_replace($line_breaks, '\\n', $item);
$this->stream .= wordwrap($item, 70, Constants::CRLF . ' ', true) . Constants::CRLF;
return $this;
}
示例9: sendNewPassword
public function sendNewPassword($email, $newPassword)
{
$msg = "Here is your new password " . $newPassword . " Have fun!!!";
$msg = wordwrap($msg, 70);
#send mail
mail($email, "Your new password", $msg, 'From: ' . WEBMASTER_EMAIL);
}
示例10: lbf_report
function lbf_report($pid, $encounter, $cols, $id, $formname)
{
require_once $GLOBALS["srcdir"] . "/options.inc.php";
$arr = array();
$shrow = getHistoryData($pid);
$fres = sqlStatement("SELECT * FROM layout_options " . "WHERE form_id = ? AND uor > 0 " . "ORDER BY group_name, seq", array($formname));
while ($frow = sqlFetchArray($fres)) {
$field_id = $frow['field_id'];
$currvalue = '';
if ($frow['edit_options'] == 'H') {
if (isset($shrow[$field_id])) {
$currvalue = $shrow[$field_id];
}
} else {
$currvalue = lbf_current_value($frow, $id, $encounter);
if ($currvalue === FALSE) {
continue;
}
// should not happen
}
// For brevity, skip fields without a value.
if ($currvalue === '') {
continue;
}
// $arr[$field_id] = $currvalue;
// A previous change did this instead of the above, not sure if desirable? -- Rod
$arr[$field_id] = wordwrap($currvalue, 30, "\n", true);
}
echo "<table>\n";
display_layout_rows($formname, $arr);
echo "</table>\n";
}
示例11: feedbackAction
public function feedbackAction()
{
$this->view->disable();
if ($this->request->isPost()) {
$name = $this->request->getPost('name');
$email = $this->request->getPost('email');
$comment = $this->request->getPost('comment');
if (empty($name)) {
return;
}
if (empty($email)) {
return;
}
if (empty($comment)) {
return;
}
$headers = 'From: noreply@kladr-api.ru' . "\n" . 'Reply-To: ' . $email . "\n" . 'Content-Type: text/html; charset="utf-8"';
$subject = 'Новое сообщение в форме обратной связи';
$subject = '=?utf-8?B?' . base64_encode($subject) . '?=';
$message = 'Новое сообщение в форме обратной связи от ' . $name . '(' . $email . '):' . "<br/><br/>" . $comment;
$message = wordwrap($message, 70);
mail('garakh@primepix.ru', $subject, $message, $headers);
print 'y';
}
}
示例12: modify
/**
* modify the value
*
* @access public
* @param string value
* @return string modified value
*/
function modify($value, $params = array())
{
/**
* width
*/
if (!isset($params['width'])) {
$params['width'] = 72;
}
settype($params['width'], 'integer');
/**
* character used for linebreaks
*/
if (!isset($params['break'])) {
$params['break'] = "\n";
}
/**
* cut at the specified width
*/
if (!isset($params['cut'])) {
$params['cut'] = 'no';
}
$params['cut'] = $params['cut'] === 'yes' ? true : false;
$value = wordwrap($value, $params['width'], $params['break'], $params['cut']);
if (isset($params['nl2br']) && $params['nl2br'] === 'yes') {
$value = nl2br($value);
}
return $value;
}
示例13: LicenceUploaded
function LicenceUploaded()
{
$tmp_file = $_FILES['fichier']['tmp_name'];
$content_dir = dirname(__FILE__) . "/ressources/conf/upload";
if (!is_dir($content_dir)) {
mkdir($content_dir);
}
if (!is_uploaded_file($tmp_file)) {
MainPage('{error_unable_to_upload_file}');
exit;
}
$type_file = $_FILES['fichier']['type'];
if (!strstr($type_file, 'key')) {
MainPage('{error_file_extension_not_match} :key');
exit;
}
$name_file = $_FILES['fichier']['name'];
if (file_exists($content_dir . "/" . $name_file)) {
@unlink($content_dir . "/" . $name_file);
}
if (!move_uploaded_file($tmp_file, $content_dir . "/" . $name_file)) {
MainPage("{error_unable_to_move_file} : " . $content_dir . "/" . $name_file);
exit;
}
$_GET["moved_file"] = $content_dir . "/" . $name_file;
include_once "ressources/class.sockets.inc";
$socket = new sockets();
$res = $socket->getfile("aveserver_licencemanager:{$content_dir}/{$name_file}");
$res = str_replace("\r", "", $res);
$res = wordwrap($res, 50, "\n", true);
$res = nl2br($res);
MainPage($res);
}
示例14: dpp_set_post_content
function dpp_set_post_content($entry, $form)
{
//Gravity Forms has validated the data
//Our Custom Form Submitted via PHP will go here
// Lets get the IDs of the relevant fields and prepare an email message
$message = print_r($entry, true);
// In case any of our lines are larger than 70 characters, we should use wordwrap()
$message = wordwrap($message, 70);
// Send for debugging
// mail('jeremyb@brantwebdesign.com', 'Getting the Gravity Form Field IDs', $message);
// Post the form to a specific URL
function post_to_url($url, $data)
{
$fields = '';
foreach ($data as $key => $value) {
$fields .= $key . '=' . $value . '&';
}
rtrim($fields, '&');
$post = curl_init();
curl_setopt($post, CURLOPT_URL, $url);
curl_setopt($post, CURLOPT_POST, count($data));
curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($post);
curl_close($post);
}
// Handle the form differently based on form ID
if ($form["id"] == 1) {
// Application Page
$data = array("first_name" => $entry["7"], "last_name" => $entry["8"], "phone" => $entry["4"], "email" => $entry["3"], "loan_type" => $entry["5"], "loan_amount" => $entry["10"], "gross_income" => $entry["12"], "monthly_payment" => $entry["11"], "state" => $entry["9"], "time_to_call" => $entry["6"], "formName" => "Application");
post_to_url("https://login.debtpaypro.com/post/d5b826014a9552022f1292804afc72d2bc27b721/", $data);
}
}
示例15: CreateRealShipInfoText
function CreateRealShipInfoText($ship_data)
{
global $db;
global $game, $SHIPIMAGE_PATH;
$text = '<font color=#000000><table widht=500 border=0 cellpadding=0 cellspacing=0><tr><td width=250><table width=* border=0 cellpadding=0 cellspacing=0><tr><td valign=top><u>' . constant($game->sprache("TEXT30")) . '</u><br><b>' . $ship_data['name'] . '</b><br><br></td></tr><tr><td valign=top><u>' . constant($game->sprache("TEXT31")) . '</u><br>' . str_replace("\r\n", '<br>', wordwrap($ship_data['description'], 40, "<br>", 1)) . '<br><br></td></tr><tr><td valign=top><u>' . constant($game->sprache("TEXT32")) . '</u><br><img src=' . $SHIPIMAGE_PATH . 'ship' . $ship_data['owner_race'] . '_' . $ship_data['ship_torso'] . '.jpg></td></tr><tr><td valign=top><u>' . constant($game->sprache("TEXT27")) . '</u><br>';
for ($t = 0; $t < 10; $t++) {
if ($ship['component_' . ($t + 1)] >= 0) {
$text .= '- ' . $ship_components[$ship['race']][$t][$ship['component_' . ($t + 1)]]['name'] . '<br>';
} else {
$text .= constant($game->sprache("TEXT33"));
}
}
$text .= '<br></td></tr></table></td><td width=250><table width=* border=0 cellpadding=0 cellspacing=0><tr><td valign=top><u>' . constant($game->sprache("TEXT28")) . '</u><br>';
$text .= '<u>' . constant($game->sprache("TEXT13")) . '</u> <b>' . $ship_data['value_1'] . '</b><br>';
$text .= '<u>' . constant($game->sprache("TEXT14")) . '</u> <b>' . $ship_data['value_2'] . '</b><br>';
$text .= '<u>' . constant($game->sprache("TEXT15")) . '</u> <b>' . $ship_data['value_3'] . '</b><br>';
$text .= '<u>' . constant($game->sprache("TEXT18")) . '</u> <b>' . $ship_data['value_6'] . '</b><br>';
$text .= '<u>' . constant($game->sprache("TEXT19")) . '</u> <b>' . $ship_data['value_7'] . '</b><br>';
$text .= '<u>' . constant($game->sprache("TEXT20")) . '</u> <b>' . $ship_data['value_8'] . '</b><br>';
$text .= '<u>' . constant($game->sprache("TEXT21")) . '</u> <b>' . $ship_data['value_9'] . '</b><br>';
$text .= '<u>' . constant($game->sprache("TEXT22")) . '</u> <b>' . $ship_data['value_10'] . '</b><br>';
$text .= '<u>' . constant($game->sprache("TEXT23")) . '</u> <b>' . $ship_data['value_11'] . '</b><br>';
$text .= '<u>' . constant($game->sprache("TEXT24")) . '</u> <b>' . $ship_data['value_12'] . '</b><br>';
$text .= '<u>' . constant($game->sprache("TEXT29")) . '</u> <b>' . $ship_data['value_14'] . '/' . $ship_data['value_13'] . '</b><br><br>';
$text .= '<u>' . constant($game->sprache("TEXT16")) . '</u> <b>' . $ship_data['value_4'] . '</b><br>';
$text .= '<u>' . constant($game->sprache("TEXT17")) . '</u> <b>' . $ship_data['hitpoints'] . '/' . $ship_data['value_5'] . '</b><br>';
$text .= '<br></td></tr><tr><td valign=top><u>' . constant($game->sprache("TEXT34")) . '</u>:<br><img src=' . $game->GFX_PATH . 'menu_unit1_small.gif>' . $ship_data['unit_1'] . ' <img src=' . $game->GFX_PATH . 'menu_unit2_small.gif>' . $ship_data['unit_2'] . ' <img src=' . $game->GFX_PATH . 'menu_unit3_small.gif>' . $ship_data['unit_3'] . ' <img src=' . $game->GFX_PATH . 'menu_unit4_small.gif>' . $ship_data['unit_4'] . ' <img src=' . $game->GFX_PATH . 'menu_unit5_small.gif>' . $ship_data['unit_5'] . ' <img src=' . $game->GFX_PATH . 'menu_unit6_small.gif>' . $ship_data['unit_6'] . '<br></td></tr></table></td></tr></table>';
$text .= '</td></tr></table></td></tr></table><br></font>';
$text = str_replace("'", '', $text);
$text = str_replace('"', '', $text);
return $text;
}