• 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

Multiply each value in array using array_map function

Symfony/Form add attribute based on the data

OctoberCMS / Anonymous Global Scope

Laravel multi auth - Authentication user provider [] is not defined

PHPS source file - 403 Forbidden You don't have permission to access this resource

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

printing all running session variable in laravel 5.1

Issue saving card for customer

Exact alternate to mcrypt_encrypt in PHP 7.2

How to add automatically collapse/expand in content wordpress (single.php)?

Laravel s3 upload file with metadata using pre-signed url

Loading data from MySQL and populating dropdown select with jQuery Mobile, PHP

What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

PHP mail sending empty mails

How to Install Composer Require doctrine/dbal

About Contact Privacy policy Terms and conditions