php - How to increment count in the replacement string when using preg_replace? -


मेरे पास यह कोड है:

  $ count = 0; Preg_replace ('/ test /', 'test'। $ Count, $ सामग्री, -1, $ count);  

हर जगह के लिए, मैं test0 प्राप्त करता हूँ

मैं test0, test1, test2 आदि प्राप्त करना चाहूंगा।

उपयोग करें :

  $ count = 0; Preg_replace_callback ('/ test /', 'rep_count', $ सामग्री); समारोह rep_count ($ मैचों) {वैश्विक $ गिनती; वापसी 'परीक्षा' $ गिनती ++; }  

Comments

Popular posts from this blog

.net - C# List<T>.Find(x=>x.Rectangle.Contains(Point)) FAIL -

iphone - Smoothing a rounded stroke in Core Graphics -

c++ - QtQuick: QQmlApplicationEngine failed to load component qrc:/main.qml:23 Invalid attached object assignment -