• 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

Composer fails with kylekatarnls/update-helper on new homestead

Need to display only array value in JSON output

How to load Codeigniter 4 lang file into an array variable

How to remove from a multidimensional array all duplicate elements including the original?

php - add comma thousands separator but remove trailing zeros

CONCAT columns with Laravel 5 eloquent

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

Creating live search with AJAX and CodeIgniter

In PHP, which is faster: preg_split or explode?

PHP, how to convert Int value to Week days

PHP mail function is sending blank message body

How to upload mpdf file after generating to s3 bucket in php

Can't find vendor/autoload.php for Ratchet

How to create a video stream from a single dynamic image in PHP

PhP how to calculate moments with variables rows

About Contact Privacy policy Terms and conditions