{"id":1196,"date":"2020-03-17T13:37:52","date_gmt":"2020-03-17T06:37:52","guid":{"rendered":"https:\/\/www.yellowweb.id\/blog\/?p=1196"},"modified":"2020-03-17T13:37:56","modified_gmt":"2020-03-17T06:37:56","slug":"character-limit-php","status":"publish","type":"post","link":"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/","title":{"rendered":"Character Limit PHP"},"content":{"rendered":"\n<p>Tulisan kali ini akan membahas seputar pembatasan jumlah karakter dengan menggunakan fungsi yang terdapat di dalam bahasa pemrograman PHP.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Untuk membatasi jumlah karakter yang akan ditampilkan pada sebuah halaman web tentunya membutuhkan beberapa fungsi php, diantaranya adalah fungsi php strlen, substr.<\/p>\n\n\n\n<p>Teknik yang nanti akan dipraktekan, adalah bagaimana sebuah artikel akan dicoba ditampilkan, namun tidak keseluruhan atau akan dibatasi dengan jumlah karakter yang sudah ditentukan. Kejadian seperti ini kerap dijumpai pada situs atau web portal berita.<\/p>\n\n\n\n<p>untuk skripnya sebagai berikut:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\t\n\tfunction batas($string, $length){\n\t\tif(strlen($string)&lt;=($length)){\n\t\t\techo $string;\n\t\t} else {\n\t\t\t$cetak = substr($string,0,$length). '...';\n\t\t\techo $cetak;\n\t\t}\n\t}\n\n\t$text = \"It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).\";\n\n\tbatas($text,100);\n\n?><\/code><\/pre>\n\n\n\n<p>Secara garis besar pada skrip diatas tulisan akan ditampilkan hanya 100 karakter.<\/p>\n\n\n\n<p>Alternatif lain teman-teman juga dapat menggunakan JavaScript atau <a rel=\"noreferrer noopener\" aria-label=\"jQuery (opens in a new tab)\" href=\"https:\/\/www.yellowweb.id\/blog\/character-limit-textarea-jquery\/\" target=\"_blank\">jQuery<\/a>.<\/p>\n\n\n\n<p>Untuk demonya silahkan kunjungi url berikut:<\/p>\n\n\n\n<p><a href=\"https:\/\/www.yellowweb.id\/demo\/limit-char-php\/\">https:\/\/www.yellowweb.id\/demo\/limit-char-php\/<\/a><\/p>\n\n\n\n<p>Sumber referensi:<\/p>\n\n\n\n<p><a href=\"https:\/\/www.w3schools.com\/pHP\/php_ref_string.asp\">https:\/\/www.w3schools.com\/pHP\/php_ref_string.asp<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tulisan kali ini akan membahas seputar pembatasan jumlah karakter dengan menggunakan fungsi yang terdapat di dalam bahasa pemrograman PHP.<\/p>\n","protected":false},"author":1,"featured_media":1197,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[110],"tags":[519,88,520,518],"class_list":["post-1196","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-limit-character","tag-php","tag-php-limit","tag-strlen"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Character Limit PHP - YELLOWWEB.ID<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Character Limit PHP - YELLOWWEB.ID\" \/>\n<meta property=\"og:description\" content=\"Tulisan kali ini akan membahas seputar pembatasan jumlah karakter dengan menggunakan fungsi yang terdapat di dalam bahasa pemrograman PHP.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/\" \/>\n<meta property=\"og:site_name\" content=\"YELLOWWEB.ID\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-17T06:37:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-03-17T06:37:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/www.yellowweb.id\/blog\/wp-content\/uploads\/2020\/03\/character-limit.jpg?fit=600%2C290&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"290\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"yellowweb\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"yellowweb\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/character-limit-php\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/character-limit-php\\\/\"},\"author\":{\"name\":\"yellowweb\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/#\\\/schema\\\/person\\\/75188044e080844724e381ab6a5b9829\"},\"headline\":\"Character Limit PHP\",\"datePublished\":\"2020-03-17T06:37:52+00:00\",\"dateModified\":\"2020-03-17T06:37:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/character-limit-php\\\/\"},\"wordCount\":127,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/character-limit-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/character-limit.jpg\",\"keywords\":[\"limit-character\",\"php\",\"php-limit\",\"strlen\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/character-limit-php\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/character-limit-php\\\/\",\"url\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/character-limit-php\\\/\",\"name\":\"Character Limit PHP - YELLOWWEB.ID\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/character-limit-php\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/character-limit-php\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/character-limit.jpg\",\"datePublished\":\"2020-03-17T06:37:52+00:00\",\"dateModified\":\"2020-03-17T06:37:56+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/#\\\/schema\\\/person\\\/75188044e080844724e381ab6a5b9829\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/character-limit-php\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/character-limit-php\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/character-limit-php\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/character-limit.jpg\",\"contentUrl\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/wp-content\\\/uploads\\\/2020\\\/03\\\/character-limit.jpg\",\"width\":600,\"height\":290,\"caption\":\"Character Limit\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/character-limit-php\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Character Limit PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/\",\"name\":\"YELLOWWEB.ID\",\"description\":\"Kursus Web Design | Kursus Web Programming | Mobile Web Apps | Digital Marketing\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/#\\\/schema\\\/person\\\/75188044e080844724e381ab6a5b9829\",\"name\":\"yellowweb\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g\",\"caption\":\"yellowweb\"},\"sameAs\":[\"https:\\\/\\\/www.yellowweb.id\"],\"url\":\"https:\\\/\\\/www.yellowweb.id\\\/blog\\\/author\\\/yellowweb\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Character Limit PHP - YELLOWWEB.ID","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/","og_locale":"en_GB","og_type":"article","og_title":"Character Limit PHP - YELLOWWEB.ID","og_description":"Tulisan kali ini akan membahas seputar pembatasan jumlah karakter dengan menggunakan fungsi yang terdapat di dalam bahasa pemrograman PHP.","og_url":"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/","og_site_name":"YELLOWWEB.ID","article_published_time":"2020-03-17T06:37:52+00:00","article_modified_time":"2020-03-17T06:37:56+00:00","og_image":[{"width":600,"height":290,"url":"https:\/\/i0.wp.com\/www.yellowweb.id\/blog\/wp-content\/uploads\/2020\/03\/character-limit.jpg?fit=600%2C290&ssl=1","type":"image\/jpeg"}],"author":"yellowweb","twitter_card":"summary_large_image","twitter_misc":{"Written by":"yellowweb","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/#article","isPartOf":{"@id":"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/"},"author":{"name":"yellowweb","@id":"https:\/\/www.yellowweb.id\/blog\/#\/schema\/person\/75188044e080844724e381ab6a5b9829"},"headline":"Character Limit PHP","datePublished":"2020-03-17T06:37:52+00:00","dateModified":"2020-03-17T06:37:56+00:00","mainEntityOfPage":{"@id":"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/"},"wordCount":127,"commentCount":0,"image":{"@id":"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.yellowweb.id\/blog\/wp-content\/uploads\/2020\/03\/character-limit.jpg","keywords":["limit-character","php","php-limit","strlen"],"articleSection":["PHP"],"inLanguage":"en-GB","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.yellowweb.id\/blog\/character-limit-php\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/","url":"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/","name":"Character Limit PHP - YELLOWWEB.ID","isPartOf":{"@id":"https:\/\/www.yellowweb.id\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/#primaryimage"},"image":{"@id":"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/#primaryimage"},"thumbnailUrl":"https:\/\/www.yellowweb.id\/blog\/wp-content\/uploads\/2020\/03\/character-limit.jpg","datePublished":"2020-03-17T06:37:52+00:00","dateModified":"2020-03-17T06:37:56+00:00","author":{"@id":"https:\/\/www.yellowweb.id\/blog\/#\/schema\/person\/75188044e080844724e381ab6a5b9829"},"breadcrumb":{"@id":"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.yellowweb.id\/blog\/character-limit-php\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/#primaryimage","url":"https:\/\/www.yellowweb.id\/blog\/wp-content\/uploads\/2020\/03\/character-limit.jpg","contentUrl":"https:\/\/www.yellowweb.id\/blog\/wp-content\/uploads\/2020\/03\/character-limit.jpg","width":600,"height":290,"caption":"Character Limit"},{"@type":"BreadcrumbList","@id":"https:\/\/www.yellowweb.id\/blog\/character-limit-php\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.yellowweb.id\/blog\/"},{"@type":"ListItem","position":2,"name":"Character Limit PHP"}]},{"@type":"WebSite","@id":"https:\/\/www.yellowweb.id\/blog\/#website","url":"https:\/\/www.yellowweb.id\/blog\/","name":"YELLOWWEB.ID","description":"Kursus Web Design | Kursus Web Programming | Mobile Web Apps | Digital Marketing","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.yellowweb.id\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.yellowweb.id\/blog\/#\/schema\/person\/75188044e080844724e381ab6a5b9829","name":"yellowweb","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5afd1bfac26e9377e8f5e36afb624cf3690dd31cb07c3961dfbc736b9ff1912f?s=96&d=mm&r=g","caption":"yellowweb"},"sameAs":["https:\/\/www.yellowweb.id"],"url":"https:\/\/www.yellowweb.id\/blog\/author\/yellowweb\/"}]}},"_links":{"self":[{"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/posts\/1196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/comments?post=1196"}],"version-history":[{"count":2,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/posts\/1196\/revisions"}],"predecessor-version":[{"id":1199,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/posts\/1196\/revisions\/1199"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/media\/1197"}],"wp:attachment":[{"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/media?parent=1196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/categories?post=1196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yellowweb.id\/blog\/wp-json\/wp\/v2\/tags?post=1196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}