• 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

Remove categories with all childs derived from parent category

Telegram bot doesn't answer

Server-sent events in PHP (without echo or print)

array_map triple dimensional array [duplicate]

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

Sort multidimensional array by column value within a column

php mysql + create a friend request system

Appending data to an anchor tag

is there any way to validate a field that sometime is File(image) && sometime is String(Src of same image)

How to make Canonicals with PHP

How to fix " Uncaught TypeError: Argument 1 passed to JpGraphException::defaultHandler() " problem in php 7.1.3 and jpgraph 4.2.6?

Group data in a multidimensional array based on two columns

Issue saving card for customer

MISSING UPDATES FOR: MEDIA Drupal 9

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

About Contact Privacy policy Terms and conditions