• 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

phpunit - mockbuilder - set mock object internal property

Merge column values from two arrays to form an indexed array of associative arrays

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

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

Add customer email and phone in "Order" column to admin orders list on Woocommerce

Custom post type single page not working

Laravel multi auth - Authentication user provider [] is not defined

codeigniter 4 running error first time with xampp

Pass an image through AJAX [duplicate]

Add New Parameter to Existing URL using htaccess

Insert And Retrieve Data in MySQL with $.post Noob Question

Send same name multiple checkbox values via ajax

The "client_reference_id" argument is not passed

Ajax GET request fails in laravel 8

How to install php yaml on CentOs?

About Contact Privacy policy Terms and conditions