{"id":332,"date":"2009-05-15T17:49:44","date_gmt":"2009-05-15T17:49:44","guid":{"rendered":"http:\/\/www.phpmind.com\/blog\/?p=332"},"modified":"2010-07-17T01:35:45","modified_gmt":"2010-07-17T01:35:45","slug":"how-to-display-certain-number-of-words-from-a-record","status":"publish","type":"post","link":"https:\/\/www.phpmind.com\/blog\/2009\/05\/how-to-display-certain-number-of-words-from-a-record\/","title":{"rendered":"How to display certain number of words from a record?"},"content":{"rendered":"<p>I got good php tutorial to display certain number of words from database; in place of Database record you can use any other regular string.<\/p>\n<pre lang=\"php\">\r\n<?php\r\n$text = $row_recap['text'];\r\nif (strlen($text) > 300) {\r\n$ext = \"... <a href='readmore.php'>read more<\/a>\";\r\n} else {\r\n$ext = \"\";\r\n}\r\nfunction elliStr($s,$n) {\r\nfor ( $x = 0; $x < strlen($s); $x++ ) {\r\n$o = ($n+$x >= strlen($s)? $s : ($s{$n+$x} == \" \"?\r\nsubstr($s,0,$n+$x) . \"...\" : \"\"));\r\nif ( $o!= \"\" ) { return $o; }\r\n}\r\n}\r\n\r\necho (elliStr(\"$text\", 300)) . $ext;\r\n?>\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I got good php tutorial to display certain number of words from database; in place of Database record you can use any other regular string.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[20],"tags":[],"class_list":["post-332","post","type-post","status-publish","format-standard","hentry","category-easy-php"],"_links":{"self":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/comments?post=332"}],"version-history":[{"count":12,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/332\/revisions"}],"predecessor-version":[{"id":851,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/posts\/332\/revisions\/851"}],"wp:attachment":[{"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/media?parent=332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/categories?post=332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phpmind.com\/blog\/wp-json\/wp\/v2\/tags?post=332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}