Skip to content

Instantly share code, notes, and snippets.

View yvolkan's full-sized avatar
🏇
Run boy run

Volkan YILMAZ yvolkan

🏇
Run boy run
View GitHub Profile
function html_truncate($text, $length, $suffix = '…', $isHTML = true)
{
$i = 0;
$simpleTags = ['br' => true, 'hr' => true, 'input' => true, 'image' => true, 'link' => true, 'meta' => true];
$tags = [];
if ($isHTML) {
preg_match_all('/<[^>]+>([^<]*)/', $text, $m, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
foreach ($m as $o) {
if ($o[0][1] - $i >= $length) {
break;
@yvolkan
yvolkan / installment_table.php
Created March 25, 2016 15:42
How to create installment table
<?php
function nextMonths( $date ){
$dateArray = [0 => $date];
for( $i=1; $i<=12; $i++){
$new_date = date('Y-m-d', strtotime('+'.$i.' months', strtotime($date) ) );
$next_month = date('Y-m-d', strtotime('last day of next month', strtotime( end($dateArray) ) ));
if ( date('m', strtotime($new_date) ) != date('m', strtotime($next_month)) ){
$dateArray[] = $next_month;
} else {
$dateArray[] = $new_date;