Skip to main content

Posts

Showing posts from December, 2015

How to insert multiple textbox values into database in php

How to insert multiple textbox values into database in php <?php    $post_count = count($_POST['textfield']); //count textfield values $post1 = array(); //create array $post2 = array(); $post1 = $_POST['textfield']; $post2 = $_POST['textfield2']; for ($i = 0; $i <= $post_count; $i++) {     $sql[] = "INSERT INTO practice (test,test2) VALUES ('".$post1[$i]."','".$post2[$i]."')"; } foreach ($sql as $query) {     mysqli_query($con, $query); } ?>  

How to Add Three Dots to a Long String PHP

How to Add Three Dots  to a Long String  PHP  Hello friends , today we learn how to add three dots at the end of a string if string length is greater then limit. so this is the code we are using to add three Ellipsis with PHP. <?php //$content = Your String. $content = substr($content, 0, 500); $content = substr($content, 0, strrpos($content, ' ')) . " ..."; ?>  here we are using substr and strrpos functions. the substr function returns a part of a string and we are Using the start and length parameters (0,500).    and the second function strrpos , The strrpos() function finds the position of the last occurrence of a string inside another string. and the syntax of strrpos is- Syntax - strrpos( string,find,start )