עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

php | עזרה בפירוק סטרינג ולקיחת מספר תווי לפני מילה ואחרי המילה

Featured Replies

פורסם

שלום

אני רוצה להוציא ממשנה מסויים מילה, הפונקציה תיקח בנוסף 20 תווים לפני המילה ו 20 תווים אחרי המילה


$search = "system";
$post = "this is a script for my searching system on my site, it's show the result only once but not on while func";

$offset = strpos($post, $search);
$start = $offset - 20;
$end = $offset + 20;
$result = substr($post , $start, $end);
echo "Result : $result <br />";

זה הקוד

$search - זה המילה שאני רוצה למצוא במשתנה $post והקוד צריך לקחת 20 תווים לפני ו20 תווים אחרי

הקוד שהבאתי עובד רק במידה ויש תוצאה אחת

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

נוציא מהשתנה $post את המילה on שמופיע כמה פעמים

ניסיתי לעשות לולאה עם

strpost($search, $post , $i)

המשתנה $i כמובן עולה בכל כניסה ללולאה

אבל היא מחזירה אותה תשובה ..

פורסם

מהו ה-i שאתה מעביר לפונקציה? הוא צריך להיות לפחות offset + 1.

פורסם
  • מחבר

מהו ה-i שאתה מעביר לפונקציה? הוא צריך להיות לפחות offset + 1.

אההה הבנתי,

$i = 1

בתוך הלולאה

$i++

בכל מקרה אני עכשיו ינסה

עריכה:

אחרי שאני קורא את המשפט שאני לא יודע איך הגעתי לרשום, אני מבין שהוא שגוי ברמות

this is a script for my searching system on my site, it's show the result only once but not on while func

זה המשפט :)

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.