• 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

How to separate letters and digits from a string in php

codeigniter 4 running error first time with xampp

Center point of multiple gps coordinates with php

Open a popup box after receiving result from ajax

How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

PHP 8 - libxml_disable_entity_loader() has been deprecated. How do I replace the functionality it provides?

WordPress + Nginx on non-standard port behind AWS ELB results in broken links

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

How to change HTML structure inside WP <head>

SendGrid: Sending an email to multiple recipients without other emails being shown on the "to" field

get attribute from class not working php 7

How to remove index.php and index from the URL using htaccess | PHP

php curl_exec() Connection refused when retrieving a remote image

Why "Class 'GuzzleHttpClient' not found" even after Installing it in Laravel?

Telegram bot doesn't answer

About Contact Privacy policy Terms and conditions