Support » Plugin: Contact Form DB » How-to use PHP substring() with variables

  • Hi,

    In the following code, all I want to do is trim the string within the variable $[CustomerTestimonial] so that it is 140 chars long when it is returned. I would like to do something like:

    substring(${CustomerTestimonial},0,140);

    because some of the testimonials are really long. I’d like to keep them all the same length. But so far, I’ve been unable to get this to work.

    Here is the code I created:

    <h1>Testimonials</h1>
    [cfdb-html form="Customer Testimonials" show="CustomerName,CustomerTestimonial" hide="/submitted.*/" random="3" filter="CanPost~~/.*public*./i"]
    [testimonial author="${CustomerName}"]
    <div id="container">
    <div id="testimonial">${CustomerTestimonial}</div>
    </div>
    [/testimonial]
    [/cfdb-html]

    Thanks for any suggestions you might have!

    http://wordpress.org/extend/plugins/contact-form-7-to-database-extension/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Have you tried using substr() instead of substring()?

    Plugin Author Michael Simpson

    (@msimpson)

    There isn’t a way to substring it.
    But you might style your testimonial DIV to have a max size + scrollbar if. That way you limit how big they are but users can still read the whole entry if they want to scroll.

    e.g.:

    <div id="testimonial" style="max-height: 200px; overflow: auto;">${CustomerTestimonial}</div>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How-to use PHP substring() with variables’ is closed to new replies.