• 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

Get data from accuweather api url

php mysql + create a friend request system

Combine multiple columns into an array as one of the key in a results set

Cross-Origin Resource Sharing (CORS) witth Laravel and Vuejs

What will the best solution for this multiple optional filter?

PHP: How to quickly split a key=value file into associative array

XAMPP keeps showing Dashboard/Welcome Page instead of the Configuration Page

Check if string contains a value in array [duplicate]

I want a way to give path to my files which are outside of public folder in laravel

Object of class stdClass could not be converted to string error

How to make dot match newline characters using regular expressions

Changing font color in javascript

Wordpress wpdb->delete issue

Multiply each value in array using array_map function

Detect emoticons in string

About Contact Privacy policy Terms and conditions