• 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

How to set a domain name with php artisan serve

Add restriction to WooCommerce coupons by allowed user ID

Create a new line whenever an array value reaches more than 10 characters

PHP - CURL using HTTPS [closed]

How avoid Moved Permanently The document has moved here

How to extract price from given url using Xpath?

Error Class "LaravelFortifyFeatures" not found

How to create laravel storage symbolic link for production or sub domain system?

add uri parameter to Route name in laravel

How to properly set "0000-00-00 00:00:00" as a DateTime in PHP

PHPMyAdmin not working as intended at remote server. Error 500, $respond not found

With doctrine ODM, can I embed many subdocuments in a main document?

Laravel update hasMany relationship using saveMany

How to submit the custom form data in database in WordPress without plugin using ajax?

how to insert data into select2 search input after scan using qrcode

About Contact Privacy policy Terms and conditions