Program (Source Code) to Trim Whitespaces from Files… برنامج (الشفره المصدريه) لتقليم whitespaces من الملفات…
PHP is not only a very competent web development language (and part of LAMP stack). بي. اتش. بى ليست فقط مختصه جدا على الشبكه العالمية وتطوير اللغة (وجزء من كومة مصباح). It is also a very capable language for writing (command line) scripts. وهي ايضا قادرة جدا على لغة لكتابه (سطر الاوامر) مخطوطات. You can write simpler and cleaner scripts with php than perl. يمكنك ان تكتب أبسط وأكثر نظافة من مخطوطات بيرل مع بي. اتش. بى. Here is a php code which takes a file name as input, trims whitespace from each line of the file and finally saves the result back in the same file. بي. اتش. بى هنا هو القانون الذي يتخذ اسم الملف كمدخل ، وتدابير الاستثمار المتصله بالتجاره بيضاء من كل سطر من الملف واخيرا ينقذ النتيجة مرة اخرى في نفس الملف.
Save the code to a file named trim.php انقاذ المدونه الى ملف اسمه trim.php
< ?php // In-place trim, use only with array_walk() function intrim(&$value) { $value = trim($value); } if($argc > 1) { $file = file($argv[1]); array_walk($file, ‘intrim’); } // Write to stdout //echo implode(”\n”, $file); // Modify the input file data; dangerous but simple file_put_contents($argv[1], implode(”\n”, $file)); ?> <؟ بي. اتش. بى / / في - تقليم مكان ، لا تستخدم سوى مع array_walk () وظيفة intrim (& دولار قيمة) ($ قيمة = تقليم دولار (القيمه) ؛) اذا كان ($ argc> 1) ($ = الملف الملف ($ argv [ 1]) ؛ array_walk ($ ملف 'intrim') ؛) / / الكتابة الى stdout / / صدى انفجر ( "\ n" ، ملف دولار) ؛ / / تعديل الملف مدخلات البيانات ؛ خطرة ولكنها بسيطة file_put_contents دولار (argv [ 1] ، انفجر ( "\ n" ، $ ملف)) ؛؟> Run it as: من تشغيلها على النحو التالي :
php -f trim.php file_to_trim بي. اتش. بى - و trim.php file_to_trim
I use this code to trim whitespace from source code (many editors introduce unnecessary whitespace in files). أنا استخدم هذا القانون لتقليم بيضاء من شفره المصدر (لا داعي لها العديد من المحررين في ملفات بيضاء).
Filed under المقدم بمقتضى Headline News أهم الانباء , ، How To كيف , ، PHP بي. اتش. بى , ، Programming البرمجه , ، Tech Note ملاحظه تقنيه , ، Web شبكة | |
| |
RSS 2.0 ار اس اس 2،0 | |
Trackback this Article | هذه المادة |
Email this Article ارسل هذه المادة
You may also like to read ويمكنك ايضا ان تقرأ |




