• 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

Call to a member function givePermissionTo() on null

image source not readable

Malformed MIME header error in Symfony 5.3

PHP to search within txt file and echo the whole line

Navigation idle on content download

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

Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables 11 [closed]

Why i get wrong output for html markdown?

PHP array stringify

Facebook API, get page post link (PHP)

How to get an Array value inside an object in an array Php [duplicate]

Why the name of trucks are same in 2nd and 3rd record of company data retrieval?

XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection

Post Form Data To phpmyadmin Database

How to use $this->session->set_userdata in codeigniter

About Contact Privacy policy Terms and conditions