• 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 get array values using foreach in laravel

Laravel - Implicit route model binding with soft deleted data

How to change HTML structure inside WP <head>

PHPSpreadsheet - How Do I Use Auto Migration Tool

get folder directory from input type file - PHP

Pages are working fine on localhost but not running on the hosting server

How to map the two arrays with a duplicate value?

How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

Convert date and time to Jalali in Laravel

Laravel PackageManifest.php: Undefined index: name

Create tags in laravel post publishing

Laravel/ PHP: Order By Alphabetical with numbers in order [duplicate]

How to run or debug php on Visual Studio Code (VSCode)

Sentry on Symfony: how to exclude `NotFoundHttpException`

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

About Contact Privacy policy Terms and conditions