Skip to main content

php script to count the numbers from each line


A very simple php script to count the numbers from each line. Input from a textarea. I know that is quite useless but I occasionally need it to make a few counts.
You can change the delimiter (\n in this case) and use something else like a comma or a pipe (, | / \) and so on.




<?php
$datanr = empty($_POST['datanr']) ? 0 : $_POST['datanr'];
$arrnumbers = explode("\n",$datanr );

$totalnr = 0;
foreach( $arrnumbers as $singlenr){
    if(is_numeric(trim($singlenr))){
        $totalnr += trim($singlenr);
        echo 'nr.: ' . $singlenr . ' - sub: ' . $totalnr .'<br>';
    }
}

echo '<form method="POST" name="counter.php"><textarea name="datanr"></textarea><input type="submit" ></form><br>';
echo 'total: ' . $totalnr . '<br>';

?>

Comments

Popular posts from this blog

Hashes Algorithms used in different web applications

Hashes Algorithms used in different web applications. I've done this list by hand. Not all the hashes algos are correct (I've generically added md5 or ??? where is unkwnown). If you are interested send corrections and I will update it. I will publish also a better version with tabs. You can reproduce it without problems. It's part of the project mdcrack gui on sourceforge. Use the | as data separator. ----------------------------------------------------------------------------------------------------------------------------------------------------- | Title | Hash Algorithm | TablePrefix | Table Name | Website | ----------------------------------------------------------------------------------------------------------------------------------------------------- | 1C Битрикс | md5($pass) | | |http://www.1c-bitrix.ru/ | 1024cms | md5($pass) | | |http://www.1024cms.org/ | 4images | md5($pass) | | |http://ww...

2022 - Remove (the too many) Ads from Memu launcher

Simple method Download from pureapk "MEmu Launcher2" ex: MEmu Launcher2_v6.0.9_apkpure.com Install "System app remover" (root) remove from system apps the "memu launcher 2" import the "purified" MEmu Launcher2 apk with the Memu utility ("apk" on the right toolbar) Longer method Install "Export Apk" Export the memu launcher2  Install purify https://github.com/echo-devim/purify/raw/master/Purify.apk use purify with the exported memu launcher 2 Install "System app remover" (root) remove from system apps the "memu launcher 2" import the "purified" MEmu Launcher2 apk with the Memu utility ("apk" on the right toolbar)      

[FIX] cyberpunk skip dialogue disappeared - pc Y button

  open C:\Games\Cyberpunk 2077\r6\config\inputUserMappings.xml with a text editor (ex. notepad++)   find   <mapping name="SceneFastForward_Button" type="Button" > ... </mapping> example (my non working settings)     <mapping name="SceneFastForward_Button" type="Button" >         <button id="IK_Pad_DigitLeft" />         <button id="IK_Y" overridableUI="fastForward" />     </mapping> and REPLACE it with the following:     <mapping name="SceneFastForward_Button" type="Button" >         <button id="IK_Pad_B_CIRCLE" />         <button id="IK_C" overridableUI="fastForward"/>     </mapping> thanks to the vanilla xml files on nexus mods as the original source.