Update and rename parse.colona.php to colona.format.v1.php

This commit is contained in:
Namhyeon Go 2019-09-25 15:15:34 +09:00 committed by GitHub
parent 0c1e2ee8f8
commit f440a95d92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 35 deletions

View File

@ -0,0 +1,37 @@
<?php
if(!check_function_exists("decode_colona_format") {
function decode_colona_format($data) {
$lines = split_by_line($data);
$jobargs = array();
$eof = false;
$delimiter = ":";
$jobkey = "";
$jobvalue = "";
foreach($lines as $line) {
$pos = strpos($line, $delimiter);
if($pos !== false) {
$jobkey = rtrim(substr($line, 0, $pos));
$jobvalue = ltrim(substr($line, $pos + strlen($delimiter)));
if($jobvalue == "<<<EOF") {
$jobvalue = "";
$eof = true;
} else {
$jobargs[$jobkey] = $jobvalue;
}
} elseif($eof) {
if($line == "EOF;") {
$jobargs[$jobkey] = $jobvalue;
$eof = false;
} else {
$jobvalue .= $line;
}
}
}
return $jobargs;
}
}

View File

@ -1,35 +0,0 @@
<?php
function parse_colona_format($data) {
$lines = split_by_line($data);
$jobargs = array();
$eof = false;
$delimiter = ":";
$jobkey = "";
$jobvalue = "";
foreach($lines as $line) {
$pos = strpos($line, $delimiter);
if($pos !== false) {
$jobkey = rtrim(substr($line, 0, $pos));
$jobvalue = ltrim(substr($line, $pos + strlen($delimiter)));
if($jobvalue == "<<<EOF") {
$jobvalue = "";
$eof = true;
} else {
$jobargs[$jobkey] = $jobvalue;
}
} elseif($eof) {
if($line == "EOF;") {
$jobargs[$jobkey] = $jobvalue;
$eof = false;
} else {
$jobvalue .= $line;
}
}
}
return $jobargs;
}