• 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

Doctrine 2 mapping referencing unique key

Dynamic table in HTML using MySQL and php

Explode not working properly with dash

Problems getting instance of UploadedFile in Yii2

XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection

Testing subscription renewals on Stripe

how to retrieve the first and last instance of a row in pdo dataset

Creating command to backup MySql database in Laravel

PHP: Insert marker every 3 iterations

PHP only Hit Counter?

PHP Form Not Inserting

str_word_count() function doesn't display Arabic language properly

Transpose csv file data [duplicate]

protect images from being copied

PHP mail sending empty mails

About Contact Privacy policy Terms and conditions