• 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

Cache clear probem in Larave

Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, null given in

MISSING UPDATES FOR: MEDIA Drupal 9

Laravel 5.2: Unable to locate factory with name [default]

PHP7 CLI attempts to load xdebug twice - "Cannot load Xdebug - it was already loaded"

php mysql + create a friend request system

Too few arguments to function PendingResourceRegistration::name(),1 passed in C:xampphtdocsproject outesweb.php on line 18 and exactly 2 expected

How to write PHP in XSLT

Add Class in html Dynamically in PHP

How to make Canonicals with PHP

laravel sanctum Route [login] not defined

Having trouble with PDO queries (Notice: Undefined index)

Coinpayments create_transaction "ERROR: Invalid command!"

How to Generate PDF invoice to XML format using mPDF

IlluminateDatabaseQueryException could not find driver [duplicate]

About Contact Privacy policy Terms and conditions