• 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

Laravel print last executed SQL query with Query log

PHP each() function replacement

CONCAT columns with Laravel 5 eloquent

Show date difference as "20" instead of "20 years ago"

Coinpayments create_transaction "ERROR: Invalid command!"

Woocommerce Checkout - Add conditional field required if one field is filled

I want to display a sweetalert after the inserting of data in my database

Get orders by date and status woocommerce

Shopify password update using Shopify API

Querying only one row from a one to many relationship laravel

PHP mail sending empty mails

How to skip cart page on woocomerce for certain products only?

How to send parameters in soap request in php in __soapcall() function

Combine multiple columns into an array as one of the key in a results set

Input and output values for php into the browser?

About Contact Privacy policy Terms and conditions