[TxMt] Re: Unwanted newline php

Ryan Fitzer ryanfitzer at gmail.com
Fri Dec 11 07:41:18 UTC 2009


Holy cow! I can't believe I missed that. Of course, I new to server
side languages. Thanks so much for the help.

Here is the updated command for those interested (a little more efficient)

-----------------------
#!/usr/bin/php
<?php

$fstat = fstat(STDIN);
$stdin = fread(STDIN, $fstat['size']);

$pattern = '/\{(.*)\}/Us';
preg_match($pattern, $stdin, $matches);
$match = trim($matches[1], "\n");
$match = preg_split('/\n/', $match);

$properties = array();

foreach($match as $line) {
	$properties[strlen($line)] = $line;
}

ksort($properties);

$output = '{' . "\n";
foreach($properties as $line) {
	$output .= $line . "\n";
}	
$output .= '}';

echo(trim($output));

?>
-----------------------

Ryan

2009/12/10 Björn Jadelius <b at jadelius.se>:
> You just need to remove the newline between
>
>> #!/usr/bin/php
> and
>> <?php
>
> Björn Jadelius
>
> _______________________________________________
> textmate mailing list
> textmate at lists.macromates.com
> http://lists.macromates.com/listinfo/textmate
>



-- 
Ryan Fitzer
Los Angeles, CA
http://www.ryanfitzer.com
http://www.portfoliorodeo.com



More information about the textmate mailing list