• 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

Could not decode a text frame as UTF-8.

phpseclib 2.0 can not use Composer to create autoload

How can I create a Download Page with post php method?

Composer Warning: openssl extension is missing. How to enable in WAMP

PHP Download MP3 files from directory on server

301 Redirect to remove query string on homepage only

Fatal error: Trait 'LaminasDbAdapterLaminasDbAdapterAdapterInterface' not found in /var/www/vendor/laminas/laminas-db/src/Adapter/Adapter.php

Laravel Multi-language routes without prefix

Failing validation doesn't stop code execution in livewire component

HTML + PHP + PHPMAILER

Laravel websockets AWS EC2 - Connection failed

wordpress : How to specify the cause "This site can’t be reached"

str_replace or preg_replace random number from string

Converting IPv6 to IPv4 address in PHP

PHP Imap , php 7.4.3 on mac osx catalina

About Contact Privacy policy Terms and conditions