• 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 remove Deprecated SymfonyComponentDebugDebugClassLoader?

IlluminateDatabaseQueryException: SQLSTATE[HY000]: General error: 1 no such table - In clone project

PHP block shortcut in Visual Studio Code

Add rows to Single product Additional information table in WooCommerce 3.6

How to fix 'Data has already been sent to output, unable to output PDF file' in MPDF

Nginx RTMP not recording

Clients authentication and user authentication with laravel

PHP's array_map including keys

Display the default discounted price and percentage on Woocommerce products

Telegram bot doesn't answer

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

401 Unauthorized only occurring on some pages in Laravel 8

Laravel Unknown Column 'updated_at'

Installing Composer - Internal Error

PHP Print to Network Printer

About Contact Privacy policy Terms and conditions