• 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

Show only featured products in Woocommerce shop page

Transpose multidimensional array and join values with commas

if statement inside concatenation

Android Volley getParams() method not getting called for JsonObjectRequest

How to Display Data in Yajra Datatables Laravel 7?

PHP function Not Working As Expected From functions.php Include File

Creating command to backup MySql database in Laravel

Failing validation doesn't stop code execution in livewire component

No definition found for function in vendor vscode

shell errors running php exec

Uploading video to Youtube using Youtube Data API V3 and Google API Client PHP -- getting 401 (unauthorized) message

WHM Enabling mod_rewrite

Return multiple values from a function using mysqli_fetch_assoc [closed]

Laravel whole batch is cancelled if one Job fails

How to get company posts from LinkedIn via API?

About Contact Privacy policy Terms and conditions