• 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

Query Optimization, changing the queries in the loop into a single processing query

WordPress Security Standards want me to escape my html, but how to do it correctly?

SQLSTATE[HY000]: General error: 1 table posts has no column named *

How to run or debug php on Visual Studio Code (VSCode)

How to make dot match newline characters using regular expressions

Explain how this array transposing and flattening function works

Can't remotely connect to MySQL error (13) with PHP script, connecting through CLI works

What's the net::ERR_HTTP2_PROTOCOL_ERROR about?

I want to store data in new index as per my key in php [duplicate]

PHPSpreadsheet - How Do I Use Auto Migration Tool

how can I set a session variable in Drupal 8 and get it in a php script?

Webscraping Symfony/Panther: Can't get HTML

Display the WooCommerce product price inside a custom function

How to convert time from one timezone to another in PHP

How can I get a div content in php

About Contact Privacy policy Terms and conditions