-5

I have the following code:

<!DOCTYPE html>
    <html>
    <head>
        <title>E6 L7</title>
        <meta charset="utf-8">
    </head>
    <body>
    <form method="post">
    Detailed Content of the article:
    <br>
    <textarea name="full" cols="80" rows="5"></textarea>
    <br>
    Trimmed Display with the number of characters:
    <br>
    <input type="text" name="trim">
    <br>
    <input type="submit" name="sm" value="Post">
    </form>
    <?php 
    $fullcontent = $_POST['full'];
    $trimnumber = $_POST['trim'];



     ?>
    </body>
    </html>

It looks like: Screenshot

enter image description here How can I get "She is a" from the string in the screenshot? Or more generally, when I enter a number in the field "Trimmed Display with a number of characters", I would get it cut off nicely with whole words cut?. That means it will cut out "She is a" or "She is a very" but never result in "She is a ve".

Luciano
  • 1
  • 2
  • 1
    Why did you not include your PHP code in the example? All we can do without it and with your errors is assume you've done something like `$_GET['full']` instead of `$_POST['full']`. – Marty Jul 27 '16 at 04:29
  • there is no action specified in the form. after submitting form, where will be the code runs? – Jees K Denny Jul 27 '16 at 04:32
  • @JeesKDenny To the current page. – Marty Jul 27 '16 at 04:34

1 Answers1

0

You can use php's substr function.

Example: echo substr('String goes here', 0, 5); will output only Strin.

Muhammad Ali
  • 668
  • 1
  • 9
  • 24