
Originally Posted by
anchorwave
Field: First name
Must be placed on line three, starting at colum 4 and not extending past column 9.
Code:
123456789
1
2
3 Mike
4
5
6
7
8
9
I'm hoping to find some sort of PHP Class that could possible help me construct this and maybe another to interpret/validate a text file like this. Any ideas?
You can just draw what you need
PHP Code:
$format = ""
// 123456789123456789123
/*1*/." :\n"
/*2*/." :\n"
/*3*/." :\n"
/*4*/." fn____ :\n"
/*5*/." ln____ :\n"
/*6*/." age :\n"
/*7*/." title__ :\n"
/*8*/." :\n"
;
and then substitute placeholders with real data:
PHP Code:
$data = array(
'fn' => 'Donald',
'ln' => 'Knuth',
'age' => 67,
'title'=> 'The Art of Computer Programming'
);
$result = preg_replace(
"~([a-z]+)_*~e",
' substr(str_pad($data["$1"], 80), 0, strlen("$0"));',
$format
);
echo "<pre>$result</pre>";
Don't know about "class"... Try asking in "advanced" forum
Bookmarks