File: tfn.php

package info (click to toggle)
php-doc 20100521-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 59,992 kB
  • ctags: 4,085
  • sloc: xml: 796,833; php: 21,338; cpp: 500; sh: 117; makefile: 58; awk: 28
file content (42 lines) | stat: -rw-r--r-- 963 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php // vim: ts=4 sw=4

// For use in process.php

// true,false,null -> entities

function apply($input)
{
	$from = '/([^a-zA-Z$._-])(true|false|null)([^a-zA-Z$_-])/i';
	$to = "\\1&\\2;\\3";

	$lines = explode("\n",$input);

	$active = TRUE;

	foreach ($lines as $nr => $line)
	{
		$active = $active && !ereg('<programlisting',$line);
		$active = $active ||  ereg('</programlisting',$line);
        if ($active)
			$lines[$nr] = substr(preg_replace( $from , $to , $line.' ' ),0,-1);
	}

	$output = implode("\n",$lines);

	// lowercase the entities:
	$output = eregi_replace('&true;','&true;',$output);
	$output = eregi_replace('&false;','&false;',$output);
	$output = eregi_replace('&null;','&null;',$output);

	$from = '/(<constant>)?(<literal>)?&(true|false|null);(<\/constant>)?(<\/literal>)?/';
	$to = "&\\3;";
	

	$output = preg_replace($from,$to,$output);


	$output = ereg_replace('<type>&null;</type>','<type>null</type>',$output);

	return $output;

}