本文整理汇总了PHP中pretty函数的典型用法代码示例。如果您正苦于以下问题:PHP pretty函数的具体用法?PHP pretty怎么用?PHP pretty使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pretty函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
$uniquesTable = $input->getArgument('uniques');
$removalsTable = $input->getArgument('removes');
$columns = explode(':', $input->getArgument('columns'));
$fillerMode = (bool) $input->getOption('fillerMode');
$this->info('Adding new ids to removes table...');
$affectedRows = $this->insertNewIdsToRemovesTable($uniquesTable, $removalsTable, $columns, $fillerMode);
$this->feedback('Linked ' . pretty($affectedRows) . ' records on new_id in ' . $removalsTable);
}
示例2: pretty
function pretty($arr, $level = 0)
{
$tabs = "";
for ($i = 0; $i < $level; $i++) {
$tabs .= " ";
}
foreach ($arr as $key => $val) {
if (is_array($val)) {
print_r($tabs . $key . " : " . ">" . "<br />");
pretty($val, $level + 1);
} else {
if ($val && $val !== 0) {
print_r($tabs . $key . " " . $val . ">" . "<br />");
}
}
}
}
示例3: reverseRemap
protected function reverseRemap($remapTable, $removesTable, $foreignKey, $startId)
{
$totalAffectedRows = 0;
$totalRows = $this->pdo->getTotalRows($removesTable);
$i = is_null($this->db->table($remapTable)->find($startId)) ? $this->db->table($remapTable)->min('id') : $startId;
while (is_int($i)) {
$remapRow = keysToLower($this->db->table($remapTable)->find($i));
$remapRowFk = $remapRow[$foreignKey];
if (!is_null($remapRowFk)) {
$newId = $this->db->table($removesTable)->find($remapRowFk)['new_id'];
if (!is_null($newId)) {
$affectedRows = $this->db->table($remapTable)->where('id', $i)->update([$foreignKey => $newId]);
$totalAffectedRows += $affectedRows;
$this->feedback('Remapped ' . pretty($totalAffectedRows) . ' rows');
} else {
$this->feedback($removesTable . '.' . $foreignKey . ' was null. continuing...');
}
} else {
$this->feedback($remapTable . '.' . $foreignKey . ' was null. continuing...');
}
$i = $this->pdo->getNextId($i, $remapTable);
}
return $totalAffectedRows;
}
示例4: execute
public function execute(InputInterface $input, OutputInterface $output)
{
$this->output = $output;
$originalTable = $input->getArgument('originalTable');
$uniquesTable = $originalTable . '_uniques';
$removalsTable = $originalTable . '_removes';
$columns = explode(':', $input->getArgument('columns'));
$firstRun = !$this->pdo->tableExists($uniquesTable);
$this->info('Counting duplicate rows...');
if ($firstRun) {
$dupes = $this->pdo->getDuplicateRowCount($originalTable, $columns);
} else {
$dupes = $this->pdo->getDuplicateRowCount($uniquesTable, $columns);
}
if ($dupes === 0) {
$this->feedback('There are no duplicates using columns: ' . commaSeperate($columns));
die;
} else {
$undedupedTable = $firstRun ? $originalTable : $uniquesTable;
$this->feedback('There are ' . pretty($dupes) . ' dupes in ' . $undedupedTable . ' on ' . commaSeperate($columns));
}
if ($firstRun) {
$this->info('Creating uniques table: ' . $uniquesTable);
$this->pdo->statement('CREATE TABLE ' . $uniquesTable . ' LIKE ' . $originalTable);
$this->feedback('Created uniques table');
if (!$this->pdo->indexExists($originalTable, implode('_', $columns))) {
$this->info('Creating comp index on ' . $originalTable . ' on ' . commaSeperate($columns) . ' to speed process...');
$this->pdo->createCompositeIndex($originalTable, $columns);
$this->feedback('Created composite index on ' . $originalTable);
}
$this->info('Creating removals table: ' . $removalsTable);
$this->pdo->statement('CREATE TABLE ' . $removalsTable . ' LIKE ' . $originalTable);
$this->feedback('Created removals table');
$this->info('Adding new_id field to ' . $removalsTable . ' to store the id from ' . $uniquesTable . '...');
$this->pdo->addIntegerColumn($removalsTable, 'new_id');
$this->feedback('Added new_id field to ' . $removalsTable);
} else {
$this->info('Creating temp_uniques table...');
$tempTable = 'temp_uniques';
$this->pdo->statement('CREATE TEMPORARY TABLE ' . $tempTable . ' LIKE ' . $uniquesTable);
$this->feedback('Created temporary table: ' . $tempTable);
}
if (!$this->pdo->indexExists($uniquesTable, implode('_', $columns))) {
$this->info('Creating comp index on ' . $uniquesTable . ' on ' . commaSeperate($columns) . ' to speed process...');
$this->pdo->createCompositeIndex($uniquesTable, $columns);
$this->feedback('Created composite index on ' . $uniquesTable);
}
$dedupedTable = $firstRun ? $uniquesTable : $tempTable;
$this->info('Inserting current unique rows on ' . $undedupedTable . ' to ' . $dedupedTable . '...');
$affectedRows = $this->insertUniquesToTable($undedupedTable, $dedupedTable, $columns);
$this->feedback('Inserted ' . pretty($affectedRows) . ' unique rows from ' . $undedupedTable . ' to ' . $dedupedTable);
$this->info('Inserting duplicate rows to ' . $removalsTable . '...');
$affectedRows = $this->insertDuplicatesToRemovalsTable($undedupedTable, $dedupedTable, $removalsTable);
$this->feedback('Inserted ' . pretty($affectedRows) . ' duplicates to ' . $removalsTable);
if (!$this->pdo->indexExists($removalsTable, implode('_', $columns))) {
$this->info('Adding comp index to ' . $removalsTable . ' on ' . commaSeperate($columns) . ' to speed process...');
$this->pdo->createCompositeIndex($removalsTable, $columns);
$this->feedback('Added composite index for ' . $removalsTable);
}
if (!$firstRun) {
$this->info('Deleting duplicate rows in ' . $uniquesTable . '...');
$affectedRows = $this->deleteDuplicatesFromUniquesTable($uniquesTable, $removalsTable);
$this->feedback('Deleted ' . pretty($affectedRows) . ' rows ' . $removalsTable);
}
}
示例5: event_column_select
function event_column_select()
{
global $wpdb;
global $pagenow;
if (is_admin() && $_GET['post_type'] == 'event' && $pagenow == 'edit.php') {
$event_types = array('iscp-talk', 'exhibition', 'open-studios', 'event', 'off-site-project');
echo '<select name="event_type">';
echo '<option value="">' . __('Event Type', 'textdomain') . '</option>';
foreach ($event_types as $value) {
$selected = !empty($_GET['event_type']) && $_GET['event_type'] == $value ? 'selected="selected"' : '';
echo '<option ' . $selected . 'value="' . $value . '">' . pretty($value) . '</option>';
}
echo '</select>';
}
}
示例6: pretty_all
function pretty_all($array)
{
//prepare an array of text messages for tidy display as HTML
foreach ($array as $key => $val) {
$array[$key] = pretty($val);
}
return $array;
}
示例7: out
function out($data, $pretty = true)
{
$json = json_encode($data);
echo $pretty ? pretty($json) : $json;
}
示例8: parse
/**
* Parses an exception into a content type
* @access public
* @param Exception $e The exception to parse
* @param string $contentType The type of content to return
* @param string $recoverer The recoverer used to recover from the exception
* @return string A parsed verion of the exception as the supplied content type
*/
public static function parse(Exception $e, $contentType = self::HTML, $recoverer = null)
{
$out = '';
switch ($contentType) {
default:
case self::PLAINTEXT:
$out .= sfl('###### ATSUMI has caught an Exception : %s', date(DATE_ATOM));
$out .= sfl("\n" . ' >> %s <<', $e->getMessage());
$out .= sfl("\n" . 'Exception type: %s', get_class($e));
if ($e instanceof ErrorException) {
$out .= sfl("\n" . 'Severity level: ' . $e->getSeverity());
}
$out .= sfl("\n" . '%s #%s', $e->getFile(), $e->getLine());
/* Show the request URL if avalable */
if (isset($_SERVER) && is_array($_SERVER) && array_key_exists('HTTP_HOST', $_SERVER) && array_key_exists('REQUEST_URI', $_SERVER)) {
$out .= sfl("\nRequest: http://%s", $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
/* Show the referer URL if avalable */
if (isset($_SERVER) && is_array($_SERVER) && array_key_exists('HTTP_REFERER', $_SERVER)) {
$out .= sfl("\nReferer: %s", $_SERVER['HTTP_REFERER']);
}
if (!is_null($recoverer)) {
$out .= sfl("\n" . 'Recoverer: %s()', is_object($recoverer) ? get_class($recoverer) : $recoverer);
$out .= sfl('Recoverer action: %s', $recoverer->getActionDetails());
}
if (isset($e->details) && !is_null($e->details)) {
$out .= sfl("\n" . '-Additional Detail');
$out .= sfl('%s', pretty($e->details));
}
if ($e instanceof atsumi_AbstractException) {
$out .= sfl("\n" . '-How to resolve this issue');
$out .= sfl($e->getInstructions('text/plain'));
}
$out .= sfl("\n" . '-Stack Trace');
$out .= sfl('%s', atsumi_ErrorParser::formatTrace($e->getTrace()));
$out .= sfl('###### End of Exception ' . "\n\n");
break;
case 'text/html':
$out .= sfl(self::getHtmlCss());
$out .= sfl('<div class="atsumiError">');
$out .= sfl('<h3><strong>ATSUMI</strong> has caught an Exception : <strong>%s</strong></h3>', date(DATE_ATOM));
$out .= sfl('<h1>%s</h1>', $e->getMessage());
$out .= sfl('<h4>Exception type: <strong>%s</strong></h4>', get_class($e));
if ($e instanceof ErrorException) {
$out .= sfl('<h4>Severity level: <strong>%s</strong></h4>', $e->getSeverity());
}
$out .= sfl('<h2>%s #<strong>%s</strong></h2>', preg_replace('|\\/([a-zA-Z0-9\\-\\_\\.]+\\.php)|', '/<strong>\\1</strong>', htmlentities($e->getFile())), $e->getLine());
/* Show the request URL if avalable */
if (isset($_SERVER) && is_array($_SERVER) && array_key_exists('HTTP_HOST', $_SERVER) && array_key_exists('REQUEST_URI', $_SERVER)) {
$out .= sfl("<h4>Request: <strong><a href='http://%s'>http://%s</a></strong></h4>", $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
}
/* Show the referer URL if avalable */
if (isset($_SERVER) && is_array($_SERVER) && array_key_exists('HTTP_REFERER', $_SERVER)) {
$out .= sfl("<h4>Referer: <strong><a href='%s'>%s</a></strong></h4>", $_SERVER['HTTP_REFERER'], $_SERVER['HTTP_REFERER']);
}
if (!is_null($recoverer)) {
$out .= sfl('<h4>Recoverer: <strong>%s()</strong></h4>', is_object($recoverer) ? get_class($recoverer) : $recoverer);
$out .= sfl('<h4>Recoverer action: <strong>%s</strong></h4>', $recoverer->getActionDetails());
}
if (isset($e->details) && !is_null($e->details)) {
$out .= sfl('<br /><h3>Additional Detail</h3>');
$out .= sfl('<div class="atsumiDetailsContainer"><pre>%s</pre></div>', pretty($e->details));
}
if ($e instanceof atsumi_AbstractException) {
$out .= sfl('<br /><h3><strong>ATSUMI</strong>: How to resolve this issue</h3>');
$out .= sfl('<div class="atsumiDetailsContainer">%s</div>', $e->getInstructions('text/html'));
}
$out .= sfl('<br /><h4>Stack Trace</h4>');
$out .= sfl('<div class="atsumiDetailsContainer"><pre>%s</pre></div>', atsumi_ErrorParser::formatTrace($e->getTrace(), 'text/html'));
$out .= sfl('</div>');
break;
}
return $out;
}
示例9: array_sum
$remove[$merge_start][] = $time;
$average[$merge_start] = ($merge_start + array_sum($remove[$merge_start])) / (count($remove[$merge_start]) + 1);
continue;
} else {
$merge_start = $time;
continue;
}
}
// make sure we convert back to date('Y-m-d H:i:s',$time);
// delete $remove[];
// update $average;
if (!empty($remove)) {
echo join("\n", $times) . "\n";
}
foreach ($remove as $mt => $times) {
foreach ($times as $t) {
$t = pretty($t);
echo "Removing {$t}\n";
$db->query("delete from trends where tag_id={$id} and woeid={$woeid} and time='{$t}'");
}
$pmt = pretty($mt);
$pav = pretty($average[$mt]);
echo "Moving {$pmt} to {$pav}\n";
$db->query("update trends set time='{$pav}' where time='{$pmt}' and tag_id={$id} and woeid={$woeid}");
}
}
}
function pretty($time)
{
return date('Y-m-d H:i:s', $time);
}
示例10: appendLogFile
/**
* Appends a html representation of the data to a log file
* @access protected
* @param mixed $data The data to log
*/
protected function appendLogFile($data)
{
$fp = fopen($this->fileLogPath, 'a');
fwrite($fp, pretty($data) . PHP_EOL);
fclose($fp);
}
示例11: get_post
<?php
$title = get_post($post)->post_title;
$slug = get_post($post)->post_name;
$id = get_post($post)->ID;
$today = new DateTime();
$today = $today->format('Ymd');
$event_classes = $event_type_param . ' ' . $year_param;
$page_url = get_the_permalink();
$delay = $post->delay;
$paged = 1;
if ($query_vars) {
$slug = $query_vars['pagename'];
$paged = $query_vars['paged'];
$event_type_param = $query_vars['type'];
$year_param = $query_vars['date'];
$upcoming_ids = $query_vars['upcoming_ids'];
$post = get_page_by_path($slug, OBJECT, 'page');
$events_section = $query_vars['events_section'];
$page_param = $slug;
} else {
$event_type_param = get_query_var('type');
$year_param = get_query_var('date');
}
$event_type_param_title = pretty($event_type_param);
示例12: pretty
$First = false;
$Str = "<TABLE cellpadding=2>";
$Str .= "<TR><TH align-left>" . pretty($Key) . "</TH>";
foreach ($before as $header) {
$Str .= "<TH align=right>" . pretty($header[$Key]) . "</TH>";
}
$Str .= "<TH align=right>" . pretty($Value) . "</TH>";
foreach ($after as $footer) {
$Str .= "<TH align=right>" . pretty($footer[$Key]) . "</TH>";
}
$Str .= "</TR>";
} else {
// same as first except no TABLE and TH replaced by TR
$Str .= "<TR><TD align-left>" . pretty($Key) . "</TD>";
foreach ($before as $header) {
$Str .= "<TD align=right>" . pretty($header[$Key]) . "</TD>";
}
$Str .= "<TD align=right>" . pretty($Value) . "</TD>";
foreach ($after as $footer) {
$Str .= "<TD align=right>" . pretty($footer[$Key]) . "</TD>";
}
$Str .= "</TR>";
}
}
$Str .= "</TABLE>";
echo "<HR>{$Str}<HR>";
// show on web page
$Mail[$Values['email']] = $Str;
// save for session variable
}
$_SESSION['Mail'] = $Mail;
示例13: count
$table["rdf:type (ignored)"] = $rdftype;
$table["owlproperty (ignored)"] = $owlproperty;
$table["classes (ignored)"] = count($classes);
$table["Objects"] = $resourceobjects;
$table["Triples"] = $triples;
$table["Triples_with_Object_ratio"] = pretty($resourceobjects, $triples);
$table["unique_subjects"] = count($uniquesubjects);
$table["subsAreObjects"] = count($subsAreObjects);
$table["subsAreObjectsRatio"] = pretty(count($subsAreObjects), count($uniquesubjects));
$table["avg_indegree_subjects"] = avg($subsAreObjects);
$table["avg_outdegree_subjects"] = avg($uniquesubjects);
$table["unique_predicates"] = count($uniquepredicates);
$table["avg_usage_predicates"] = avg($uniquepredicates);
$table["unique_objects"] = count($uniqueobjects);
$table["objsAreSubjects"] = count($objsAreSubjects);
$table["objsAreSubjectsRatio"] = pretty(count($objsAreSubjects), count($uniqueobjects));
$table["avg_indegree_objects"] = avg($uniqueobjects);
$table["avg_outdegree_objects"] = avg($objsAreSubjects);
p($table);
if ($detailed) {
echo "classes\n";
detailed($classes);
echo "predicates\n";
detailed($uniquepredicates);
}
}
//foreach
function detailed($arr)
{
foreach ($arr as $key => $value) {
echo "{$key}\t{$value}\n";
示例14: pretty
function pretty($value, $prefix = '')
{
if (is_null($value)) {
return 'null';
}
if (is_string($value)) {
return '\'' . str_replace(array('\'', "\n", "\r", "\t"), array('\\\'', '\\n', '\\r', '\\t'), $value) . '\'';
}
if (is_int($value)) {
return (string) $value;
}
if (is_double($value)) {
return (string) $value;
}
if (is_bool($value)) {
return $value ? 'true' : 'false';
}
if (is_array($value)) {
$ret = 'array(';
if (count($value) <= 0) {
return $ret . ')';
}
foreach ($value as $a => $b) {
$ret .= "\n " . $prefix . pretty($a) . ': ' . pretty($b, ' ' . $prefix);
}
$ret .= "\n" . $prefix . ')';
return $ret;
}
if (is_object($value)) {
$ret = '';
if (method_exists($value, 'toString')) {
$ret = $value->toString();
}
$ret = $ret . ' ' . get_class($value) . '(';
if (method_exists($value, 'dumpDebug')) {
$value = $value->dumpDebug();
}
foreach ($value as $a => $b) {
$ret .= "\n " . $prefix . $a . ': ' . pretty($b, ' ' . $prefix);
}
$ret .= "\n " . $prefix . ')';
return $ret;
}
return '?' . gettype($value) . '?';
}
示例15: getNumOfFeatures
} else {
if ($method == "quec") {
$data = getNumOfFeatures($map, $layer, $attribute);
$breaks = quantile($data, $classes);
$colors = getColors(hex2rgb($startColor), hex2rgb($endColor), count($breaks));
saveToMapFile($map, $layer, $attribute, $type, $breaks, $colors, $mapFile);
} else {
if ($method == "sd") {
$data = getNumOfFeatures($map, $layer, $attribute);
$breaks = standardDeviation($data, $classes);
$colors = getColors(hex2rgb($startColor), hex2rgb($endColor), count($breaks));
saveToMapFile($map, $layer, $attribute, $type, $breaks, $colors, $mapFile);
} else {
if ($method == "pb") {
$data = getNumOfFeatures($map, $layer, $attribute);
$breaks = pretty($data, $classes);
$colors = getColors(hex2rgb($startColor), hex2rgb($endColor), count($breaks));
saveToMapFile($map, $layer, $attribute, $type, $breaks, $colors, $mapFile);
}
}
}
}
}
}
}
}
} else {
if ($_POST["function"] == "updateStyles") {
$mapFile = $_POST["mapFile"];
$layerName = $_POST["layerName"];
$data = json_decode($_POST["data"]);