• 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

Need to display only array value in JSON output

Make Calculator - When Button clicked the No shows in Textbox.

How can I access an array/object?

possible options to create pdf file using html elements to generate invoice in php and codeigniter

CodeIgniter force_download is not working

Undefined Array Key error when uploading image on php

Laravel 4 Redirect::back() not going to previous page (refreshing current page)

Destroy session upon refresh

PHP - Store information with NO database

Laravel Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) on a sub query with "ROW_NUMBER() OVER PARTITION"

How to map the two arrays with a duplicate value?

Update Order custom Field value with WooCommerce REST API

Call to undefined function openssl_decrypt

Toggle between a textbox and a select using PHP

Get Header Authorization value of a login api (sent with username and password in json body) using php curl

About Contact Privacy policy Terms and conditions