I would like to iterate over an array and from that array create a string. However, each string needs to be of certain size (500 bytes).
So my array looks like:
Array
(
[0] => Array
(
[name] => shirt
[price] => 1.25
)
[1] => Array
(
[name] => car
[price] => 25.10
)
...
)
$str = "";
foreach($arr as $v) {
$str .= "<name>".$v['name']."</name>";
$str .= "<price>".$v['price']."</price>";
}
Output should be something like:
str1 = '<name>shirt</name><price>1.25</price><name>car</name><price>25.10</price>...' // until 500 bytes or less.
str2 = '<name>shirt</name><price>1.25</price><name>car</name><price>25.10</price>...' // until 500 bytes or less.
// I need complete tags. So I can't have a string that looks like:
str = '<name>flower</name><pri';