• 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

Store / Website Column in Magento 2 Admin Grid - Custom Module

xdebug 3 not working in ubuntu 20.04 with docker

How to identify whether webp image is static or animated?

Composer fails with kylekatarnls/update-helper on new homestead

php - add comma thousands separator but remove trailing zeros

Wordpress wpdb->delete issue

Convert PHP array into HTML tag attributes separated by spaces

selected value from the listbox in php

Use Python plotly chart in PHP

PHP block shortcut in Visual Studio Code

Pagekite error: FAIL: localhost:8080 is down

Select option from dropdown menu with PHP and mySql

How to execute sql code based on fetch array

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

PHP error: "The zip extension and unzip command are both missing, skipping."

About Contact Privacy policy Terms and conditions