Add table string inside html php variable


We can use strrpos function to find the position of the string and use substr function to insert the particular string in particular position.

<?php
$html = "\html/Please Click Here to Complete Questionnaire/html/"
$str_to_insert = "pramodh";
$pos = strrpos($html,"Please Click Here to Complete Questionnaire")+10;
//$newstr = substr_replace($html, $str_to_insert, $pos, 0);
$str = stripslashes(substr($html, 0, $pos) . $str_to_insert . substr($html, $pos));
//echo strrpos("I love php too!","php");
//var_dump($str);
var_dump(strrpos($str,"prmodh”)) ;
var_dump(json_encode($str));
?>

About

myself pramodh kumar yet another php developer from India and have worked on oops,procedural,yii framework,codeigniter,wordpress,joomla,api and more.

Tagged with: , , , , , , ,
Posted in Practice Makes a beginner to become php programmer expert(practical task to become php programmer)

Leave a comment

Follow Tutorial on WordPress.com
categories
Calendar
April 2018
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
30  
Follow me on Twitter
Blog Stats
  • 88,191 hits