• 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

Why does codeigniter & Linux server throws unserialize() session data error when user tries to login

Symfony 4: how to allow dynamic values for array nodes in bundle configuration?

Pagekite error: FAIL: localhost:8080 is down

How to make dot match newline characters using regular expressions

Convert date and time to Jalali in Laravel

php: command not found Command PhaseScriptExecution failed with a nonzero exit code

How to use a PHP MVC Controller, one thats invoked by calling a URL, to call and execute more than one function? [duplicate]

Php - Sum up the numbers in an array one by one

Update Order custom Field value with WooCommerce REST API

Inserting Country Selection into MySQL PHP [duplicate]

Why is this PHP array not the same?

Make Calculator - When Button clicked the No shows in Textbox.

Laravel Sanctum CSRF not authenticating

How to install php_imagick on wamp64

PHP array slice from position + attempt to return fixed number of items

About Contact Privacy policy Terms and conditions