• 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

generating a random code in php?

PHP's array_map including keys

laravel MVC execution flow

Get sum of arrays inside array

Is there a way to use the same parameter into multiple place in the same query with Eloquent? [duplicate]

How to identify whether webp image is static or animated?

How to install php yaml on CentOs?

Laravel Nova Dependency Container what are the allowed resource properties other than id in dependsOn

virtctl works when executed via command line but not from php exec()

generate an Excel file using PHP

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

Make Shipping Method fields Mandatory on Woocommerce checkout page

Correctly determine if date string is a valid date in that format

PHP Startup: Unable to load dynamic library 'openssl' in Ubuntu

Send same name multiple checkbox values via ajax

About Contact Privacy policy Terms and conditions