• 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

Transpose multidimensional array and join values with commas

Create tags in laravel post publishing

display WooCommerce “Add to cart” button with short-code [add_to_cart ] dynamically

Xdebug in Laravel is not working with VSCode

Having issue with matching rows in the database using PDO

Magento 2 - Controller returning blank page

How to create laravel storage symbolic link for production or sub domain system?

get data-value with variable value

Detect a fetch request in PHP

Update Order custom Field value with WooCommerce REST API

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

echo language construct is discouraged. (PHP)

How to send upload image through email

using random function but it's displaying duplicates

Sync Records With Default Values in Pivot Tables, Call to undefined method syncWithPivotDefaults()

About Contact Privacy policy Terms and conditions