Jump to content

using substr/str_replace on a variable


croakingtoad

Recommended Posts

Greetings!  I am querying a database and after a little magic it outputs a variable called - $HomeStyle

 

Now, this is a migration script so I am migrating from a database that has a field length of 3000 to a database that has a field length of 250.

Here's a sample value:

$HomeStyle= "Adirondack-style,Cabin,Cedar shake,Conventional,Cottages,Farmhouse,Lake";
//Obviously this is less than the needed field length, but let's just pretend so we can save space!

 

So how would I take the value of $HomeStyle, reduce it to 250 AND eliminate any characters after the last comma (including the last comma)?  (So we don't have incomplete words.)

 

Thanks for your guidance!

Link to comment
https://forums.phpfreaks.com/topic/104871-using-substrstr_replace-on-a-variable/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.