• 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

display WooCommerce “Add to cart” button with short-code [add_to_cart ] dynamically

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

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

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

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

PHP 8.1: strftime() is deprecated

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

Facebook API, get page post link (PHP)

Adding hreflang tags automatically in WordPress subdirectory multisite

Hi, I am making a contact form thingy, and my php isn't working any reason why?

Xdebug 3 not showing in phpinfo on m1 Monterey

Natural ORDER in Laravel Eloquent ORM

Call authenticate manually in router middleware

How to execute sql code based on fetch array

Laravel s3 upload file with metadata using pre-signed url

About Contact Privacy policy Terms and conditions