foreach trimming characters and I'm not telling it to!
I've cleaned this up to where I know there is an issue. Bluntly I've got a foreach statement cutting off all by one character of the results. Example in comments below.
print_r($getarticlemultiarray);
/// this print_r returns good values like [title] => titletext [body] => bodytext
foreach ($getarticlemultiarray as $zyz) {
ec开发者_开发百科ho $zyz['title'];
// here is the problem. This echo statement is only throwing out 1 character
// for example with the values in the example above it's just echoing a 't'.
} // end foreach
This foreach is nested inside another one, but I'm not doing anything with string lengths, and I am not using $zyz anywhere else. Nothing strange but normal words with no special characters either.
Based on what you have said, it looks like your print_r is essentially
Array (
['title'] => 'titletext',
['body'] => 'bodytext
)
In that case, your foreach
is setting $zyz
to titletext
and bodytext
, respectively. These strings have no 'title' key. PHP will treat these key as 0 which in turn returns the first character (hence why you see a 't'). Seems like you don't have to loop here.
精彩评论