Jump to content

manipulating strings


fohanlon

Recommended Posts

Hi Guys

 

I have a string with a max characters of 612, this equates to 4 strings each of length 153 characters.

 

Here is the issue, for every euro symbol in each of the 4 substrings each takes up 2 characters. So for example if there are 5 euro symbols in the first set of 153 characters, I want to push 5 characters into the second set of 153 characters as each euro takes up 2 characters and adjust the 3rd and 4th 153 substring accordingly and so on.

 

Also there is the added complication if there are euro symbols in the last few characters of each 153 characters substring.

 

I canot find a suitable function to help here.

 

I was thinging of starting with:

 

$num_euros1 = 2 * substr_count(substr($Content, 0, 153), '€');

$num_euros2 = 2 * substr_count(substr($Content, 153, 153), '€');

$num_euros3 = 2 * substr_count(substr($Content, 306, 153), '€');

$num_euros4 = 2 * substr_count(substr($Content, 459, 153), '€');

 

I am stuck on this one.

 

Regards

 

Fergal.

Link to comment
https://forums.phpfreaks.com/topic/248840-manipulating-strings/
Share on other sites

Is this correct: You ONE string that's 612 characters long. you want to look at the first 153 characters in that string and find all the euro characters. And you claim that takes up 2 character spaces of the string.

 

How do you figure? I use € for a euro symbol in php and that's more than two characters. What characters are you looking for in the first 153 characters of the string?

 

 

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.