html - Get values in between specific tag using PHP GetBetween -
i split text in between < li> , < /li> tag contents , display textarea.
my database values saved in following format
<ul> <li>test1</li> <li>test2</li> <li>test3</li> <li>test3</li> </ul>
i fetch each value in between < li > , < /li > , display in textarea. (maximum 4 text-areas).
<?php $sql="select * product_name"; $result=mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_array($result); function getbetween($value1="",$value2="",$dbvalue){ $temp1 = strpos($pool,$value1)+strlen($value1); $result = substr($dbvalue,$temp1,strlen($dbvalue)); $dd=strpos($result,$value2); if($dd == 0){ $dd = strlen($result); } return substr($result,0,$dd); ?> <textarea name="description1"> <?php echo getbetween("<li>","</li>",$row['description']);?> </textarea> <textarea name="description2"></textarea> <textarea name="description3"></textarea> <textarea name="description4"></textarea>
in first textarea database values fetching. not know how display 2,3 , 4 each values respective textares.
i expecting following output:
<textarea name="description1">test1</textarea> <textarea name="description2">test2</textarea> <textarea name="description3">test3</textarea> <textarea name="description4">test4</textarea>
please me. thanks
i suggest example:
<?php $str = "<ul> <li>test1</li> <li>test2</li> <li>test3</li> <li>test3</li> </ul>"; preg_match_all('/<li ?.*>(.*)<\/li>/',$str,$matches); if(!empty($matches[1])){ foreach($matches[1] $key=>$text){ echo '<textarea name="description'.($key+1).'">'.$text.'</textarea>'; } } }
Comments
Post a Comment