Search the Community
Showing results for tags 'foreach()'.
-
I've made this code for a very simple registration form practice: //assign form variables $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $username = $_POST['username']; function clean_names($dirty_name) { strip_tags($dirty_name); str_replace(' ', '', $dirty_name); ucfirst(strtolower($dirty_name)); //return $dirty_name; } $names = array($firstname, $lastname, $username); if(isset($_POST['register_button'])) { // WHY IS THIS FUNC CALL NOT WORKING?? foreach($names as $name) { clean_names($name); } echo "First Name: " . $firstname . "<br>"; echo "Last Name: " . $lastname . "<br>"; echo "Username: " . $username . "<br>"; } The values are returned but they haven't been put through the clean_names function. I'm really new with PHP. Can someone tell me why this isn't working? Thank you
-
I have a blog with the blog entries in a directory (very unsecure, I know) and on my home page I have a foreach(); function that retrieves all of the files (blog entries) from the entries directory. I've posted so many entries, my homepage is taking a very long time to load. Is there any way to paginate this foreach(); function? Here is my code foreach (glob("entries/*.php") as $filename) { include $filename; }