Skip to content

Instantly share code, notes, and snippets.

View ChVuagniaux's full-sized avatar

Christophe Vuagniaux ChVuagniaux

View GitHub Profile
@ChVuagniaux
ChVuagniaux / strHelper.php
Last active April 25, 2017 14:37
Cut HTML strings without breaking words and markup
<?php
/**
* Cut HTML string before a max number of X chars without cutting a words or breaking the HTML markup.
*
* Try to cut after a </p> tag after 2/3 of the max length (for avoid to display only the first paraph) and if
* this fail Cut after the position of the last char of the last word just before the max length and add '...'
* at the end of the string
*
* usage : StrHelper::splitHtmlString($html, 1000); // For get a string that will never be bigger than 1000 chars
*

Keybase proof

I hereby claim:

  • I am ChVuagniaux on github.
  • I am chvuagniaux (https://keybase.io/chvuagniaux) on keybase.
  • I have a public key whose fingerprint is 7475 D4C9 3F61 946A 4046 24E3 5567 8CE8 E56B 1DD7

To claim this, I am signing this object:

@ChVuagniaux
ChVuagniaux / k2helper.php
Created December 19, 2016 08:40
Joomla - K2 extrafield formating helper
<?php
class K2Helper
{
/**
* Convert K2 extra fields to an object
*
* Selectable extra fields ever return values inside an array
* same if only one value is selected
*