• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Extract string between first whitespace and last whitespace in php

php


PHP Snippet 1:

<?php
$str_arr = explode(" ", "Your long sentence here.");
$sub_arr = array_slice($str_arr, 1, count($str_arr)-2);
$extracted_str = implode(' ', $sub_arr);
echo $extracted_str; // long sentence

Related Snippets

SMTP ERROR: MAIL FROM command failed: 530 5.7.0 Must issue a STARTTLS command first when using PHPMailer

Symfony - "framework.test" config is not set to true

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'posts.post' doesn't exist

disable two buttons after clicking another button

JQuery content editable div and text box on submit not sending POST

laravel 5.6 bulk inserting json data

How to add a custom field to all Woocommerce attribute terms using add_action

Display the default discounted price and percentage on Woocommerce products

Custom API and cunsuming in php?

Check If array is null or not in php

PHP returning an error message and false

How to trim a video by 4 fragments to 4 seconds using the PHP-FFMpeg?

Adding reCAPTCHA v2 into my PHP file

CSV to PHP class properties

Prestashop cUrl Login

About Contact Privacy policy Terms and conditions