php - No elements returned from array -


I asked a question about the same code, but lost in translation

here That's what comes down to the question. I certify that if there is a definite array, then I want one element from it but does not return any value. What is happening?

EDIT: I am adding code that tells where the string is coming from is a guest book where I need to come up with a solution which is not the database of the session variable. The curriculum is required; $ file = "gb_berichten.txt"; $ Date = date ("D-M-Y"); $ Bericht = "& lt; p>

Name: & lt; / p & gt; $ _ Post [Name] & lt; br & gt; & lt; p & gt; Email: & Lt; / p & gt; $ _ Post [Email] & lt; br & gt; & lt; p & gt; onderwerp: & lt; / p & gt; $ _ Post [subj] & lt; br & gt; & lt; b & gt; Bericht: & lt; / p & gt; $ _ Post [Bericht]
& lt; p & gt; Segment verzonden: & lt ; / B & gt; $ datum & lt; / p & gt; & lt; hour / & gt; "; If (is_writable ($ file)) {$ fp = fopen ($ file, "A") or die ("Cana de file nit open end lieutenant; brad";); FILIT ($ fp, $ bericht); Fclose ($ FP); } // end if is worth writing {print ("Best and $ file bestseller Vir Swijen"
;); } If (is_readable ($ file)) {$ fp = fopen ($ file, "r"); // $ tekst = fread ($ fp, filesize ($ file)); $ Inhoud = file_get_contents ($ file); $ Berichten = implode ('', array_reverse (explosion ("& lt; hour / & gt;", $ inhoud)); Fclose ($ fp); Print ($ berichten); } Else {print ("niet mogelijk om bestand te lezen"); } // $ berichten een is a string check if (is_string ($ berichten)) {print ("string ok"); } Other {print ("string nit ok");} // return string back into the oak // array $ berichtenArr = explode ("", $ berichten); If (is_array ($ berichtenArr)) {print ("& lt; p style = 'color: red'> OK OK

"); } Other {print ("& lt; p style = 'color: red' & gt; array is not correct & lt; p & gt;"); } // Returns right fine $ secondsEleam = $ BirchtenanArr [1]; Print ("& lt; p style = 'color: red' is another element: $ secondElem

"); // gives no value $ aantalBer = count ($ berichtenArr); Print ("& lt; p style = 'color: red'> The amount of messages: $ aantalBer

"); // return1}

you've blasted ("& lt; Hour / & gt; ") , but in your other comments, you indicate that your string contains multiple & lt; Hr / & gt; Element .

Can you solve this problem?

I will give you a clue: & lt; Hr / & gt; is not the same as & lt; Hours />.

You may modify your blast () to pick both in the account

It is also possible that you have & Lt; Hr & gt; can be in the form of other valid potential (in fact, there is much more possiblities than that, since is valid for Tags for id , category and style attributes, all of which were remembered by a simple explosion ()

If you want to select all valid possibilities, then use something like you to preg_split () instead. (Note, though And I suggest that, I should add that it is generally considered a bad form to use a regex to match the pattern in HTML. But since you are just looking for simple & lt In the, hour & gt; tag, it should be possible without having to do a good enough work with () without having to make your matching pattern very complicated).

Comments