• 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

php script to delete files older than 24 hrs, deletes all files

PHP sort array of objects by two properties

PhP how to calculate moments with variables rows

Laravel Delete and Update

Laravel implode array items to new lines

Unable to create lockable file - Laravel 8 & PHP 8

javascript html popup window

Woocommerce product attributes with hierarchy like categories

how to remove white space in select 2

find in set in laravel ? example

Match single unknown parameter php (Morse-code Regex)

jQuery Ajax Post with data

Coinpayments create_transaction "ERROR: Invalid command!"

Add a custom text for a particular product on specific email notification in Woocommerce

Using PHP to connect to a remote MSSQL database

About Contact Privacy policy Terms and conditions