הרשם שאלות ותשובות רשימת חברים לוח שנה הודעות מהיום

חזור   הוסטס - פורום אחסון האתרים הגדול בישראל > עיצוב גראפי, תכנות על כל שפותיו וקידום ושיווק אתרים > פורום תיכנות

   
|!|

 
 
כלים לאשכול תצורת הצגה
Prev הודעה קודמת   הודעה הבאה Next
ישן 21-08-09, 10:56   # 3
Shay Ben Moshe
משתמש - היכל התהילה
 
מיני פרופיל
תאריך הצטרפות: Oct 2007
הודעות: 1,397

Shay Ben Moshe לא מחובר  

Sorry for the english, I just installed Linux.
The solution is to use a foreach loop.
If this is 1d array than you should use a function like this:
PHP קוד:
function ArrSpecialChars($array) {
    foreach(
$array as $key=>$val) {
        
$array[$key] = htmlspecialchars($val);
    }

But, if it is a 2d or more array you should use something recursive like this:
PHP קוד:
function ArrSpecialChars($array) {
    foreach(
$array as $key=>$val) {
        if(
is_array($val)) {
            
$array[$key] = ArrSpecialChars($val);
        }
        
$array[$key] = htmlspecialchars($val);
    }
    return 
$array;

Of cures this one will work for both cases.

Edit:
You can use this function as a master function, for strings to arrays..
PHP קוד:
function SpecialChars($text) {
    if(
is_array($text)) {
        foreach(
$text as $key=>$val) {
            if(
is_array($val)) {
                
$text[$key] = SpecialChars($val);
            }
            
$text[$key] = htmlspecialchars($val);
        }
        return 
$text;
    }
    elseif(
is_string($text)) {
        
$text htmlspecialchars($text);
        return 
$text;
    }
    else {
        return 
false;
    }

__________________
שי בן משה - בונה אתרים
חותך אתרים, ומתכנת צד לקוח וצד שרת.

Last edited by Shay Ben Moshe; 21-08-09 at 10:59..
  Reply With Quote
 

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 


חוקי פירסום
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


כל הזמנים הם GMT +2. הזמן כעת הוא 11:09.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ