Jump to content

Recommended Posts

still didn't work. i'm getting this string from database to form like this

 

id-name-state-city-date

 

then use that as my url for my pages

 

got the id, name, state, city, date from a site then save it in our database

 

Yeah sorry I'm not sure, here's a shot in the dark...

 

<?php
$s = "tims  gsd       d     a	a...a      s asd f";
$s = html_entity_decode($s);
$s = preg_replace('/[\s|\t| ]*/' ,"" , $s);
echo $s;
?>

 

 

 

Was the data out from a single field or was it from a concatenated string?

 

If the one you are trying to trim is from one field only, then instead of having that trim side on PHP, better to disallow it when you are trying to save it in the first place.

 

I am not so sure how you saved it so am a bit confused if the previous suggestions were not working.

i'm downloading the data from a site. by using curl

stip the xml tags and separate the each tags with a delimiter

 

ex. <name>my name</name><address>my address</address>.....

then will convert that to name:my name|#|address:my address........

 

then save that to our database.

 

if i'm going to get that data, i will save it as an array so i could get the key and value.

 

now as im researching the data. i found out that in the name, it has space before and after the name

so it will be like  name: my name |#|

 

i couldn't remove that space

solve my problem. a friend of mine suggested to convert it to hex. then i get the hex of space and remove it. and it works. thank you for help guys. i appreciated your suggestions.

 

I still think that one of the ways we suggested would work...

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.