Jump to content

How to explode word using php


b4druz4lsyihab
Go to solution Solved by Psycho,

Recommended Posts

how to take a word in php or explode based on luas Bangunan :xxx
For example I have string
$string =" Kondisi Properti : Bagus Dilengkapi Perabotan : Unfurnished Sertifikat : Lainnya Daya Listrik : 2200 Watt Kamar Tidur : 3/1 Kamar Mandi : 2/1 Luas Bangunan : 92 m² Luas Tanah : 126 m² Jumlah Lantai : -
Kondisi Properti : Bagus Sekali Dilengkapi Perabotan : Unfurnished Sertifikat : SHM - Sertifikat Hak Milik Daya Listrik : 6600 Watt Saluran Telepon : 1 Garasi : 3 Kamar Tidur : 4/1 Kamar Mandi : 3/1 Luas Bangunan : 300 m² Luas Tanah : 228 m² Jumlah Lantai : 2.5 ";

eg I want to take every "Luas bangunan: xxx"
Thanks

Link to comment
Share on other sites

avshelestov solution is correct. Although $your_text needs to be changed to $string and you need to add a third argument to preg_match_all to return the array of matches. Example code.

$items = preg_match_all("!Luas\s+Bangunan\s+:\s+(\d+)!si", $string, $matches); 

echo "Found $items instances of Luas Bangunan. The values are : ' . implode(', ', $matches[1]);
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.