Solved

PHP: Everything before Zooph

Posted on 2011-02-16
2
307 Views
Last Modified: 2012-05-11
I want a string to contain everything before " Zooph"

So:
Hello, World! Zooph 123

Should become:
Hello, World!
0
Comment
Question by:hankknight
2 Comments
 
LVL 8

Accepted Solution

by:
rationalboss earned 300 total points
ID: 34912631
$word = ' Zooph';
$data = 'Hello, world! Zooph 123';

$exp = explode($word,$data);
echo $exp[0];

Open in new window

0
 
LVL 34

Assisted Solution

by:Beverley Portlock
Beverley Portlock earned 200 total points
ID: 34914034
Another way....

<?php

$word = ' Zooph';
$data = 'Hello, world! Zooph 123';

echo preg_replace('#(.*)'.$word.'.*#is', '$1', $data );

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now