<form class= "sredina" action="" method="get" class="form-signin"> <input type="text" name="niz" id="niz" placeholder="unesi" /> <input type="submit" name="submit" > </form>
<?php $numbers = ""; if (isset($_GET['submit'])) { $numbers = ($_GET['niz']); preg_match_all('/\d+/', $numbers, $zni); $numtwo= array_map('intval', $zni[0]); } foreach ($numtwo as $num) { $reverse = strrev($num); var_dump($reverse); if ($num == $reverse) { $reverse = "true"; } else { $reverse = "false"; } var_dump($reverse); }
actually there is a much simplier solution to do- <?php $input = "/43sdsd555ksldk66sd\"544fdfd"; $total = 0; preg_match_all('/\d+/', $input, $m); foreach ($m[0] as $d) if ($d == strrev($d)) $total += $d; var_dump($total); // => int(621) echo $total;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)