• 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

Explain how this array transposing and flattening function works

PHP mail sending empty mails

How to prevent phpmailer sending embedded image as an attachment on Gmail?

*** ERROR *** The PHP configuration loaded file is: c:/wamp64/bin/php/php8.1.0/php.ini - should be: c:/wamp64/bin/apache/apache2.4.53.1/bin/php.ini

Laravel phpunit test failing authorization

301 Redirect to remove query string on homepage only

How to increase the PHP upload limits [duplicate]

How can I make a full text index of the column?

java URL working on browser but not in client program

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

How to make a array inside array?

Laravel: Why is my variable not being set while it's in the construct function of the controller?

printing all running session variable in laravel 5.1

How to get variable from JavaScript to PHP [duplicate]

Display Link Title Instead of URL in XSL

About Contact Privacy policy Terms and conditions