Home > General, PHP, Programming > Magic of programing

Magic of programing

January 31st, 2010

Today I’ve been accidentally paying attention to a php code that reminds me a issue that it ain’t totally important how long has somebody been in programing world , just his ability to reduction and maintenance !
As indicated in my old publishing to seclude the usernames from passwd file , you would see the code I’ve inaccurately been satisfied with , so why and what’s the point ?
See this piece of php code :

1
2
3
4
5
6
7
8
9
10
<?php
$fp = fopen('passwd.txt','r');
$fr = fread( $fp , filesize( 'passwd.txt' ) );
preg_match_all('/(.+?):x:(.+?)/',$fr,$explode);
print_r($explode);
$fp2 = fopen('data.txt','w+');
$fw2 = fwrite($fp2,$content);
fclose($fp);
fclose($fp2);
?>

Which is exactly doing all what my damn 53 lined php code does by neither more extensively nor less so !
That time I didn’t identify preg_match_all() function as well as I do now , however it doesn’t matter at all !
If you had a new idea leave comment and if not … be safe !

General, PHP, Programming , , , ,

  1. April 1st, 2010 at 12:15 | #1

    preg_match_all() is very usefull ;
    anyway thanks….

  2. kuch
    April 3rd, 2010 at 11:07 | #2

    I liked it. So much useful material. I read with great interest.

  3. anon
    April 12th, 2010 at 15:54 | #3

    Valuable thoughts and advices. I read your topic with great interest.

  1. No trackbacks yet.