• 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

What will the best solution for this multiple optional filter?

PHP Fatal error: Class not found - PHPUnit

How to send upload image through email

Appending data to an anchor tag

Load a .env file with PHP

Laravel : How to Create Dropdown to Select FOREIGN KEY from Other Table?

(Cache::lock()) -> get() -- Under what conditions does it return false?

How to convert a carbon into string, to take the date only?

Symfony process run throws exception - executing on command line works

How can I create a Download Page with post php method?

Add rows to Single product Additional information table in WooCommerce 3.6

PHPMetrics option --excluded-dirs="myfolder" : myfolder dir is not excluded within docker

How to load Codeigniter 4 lang file into an array variable

Check If array is null or not in php

Remove country code from phone number?

About Contact Privacy policy Terms and conditions