Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8381329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:40:32+00:00 2026-06-09T16:40:32+00:00

I have a templating system for a current project. I use str_replace() to replace

  • 0

I have a templating system for a current project. I use str_replace() to replace tokens within HTML documents with dynamic data.

For example, {%TEAM_NAME%} would be replaced with a name of a team taken from a table dependent on certain factors.

In one case the number of tokens (or string length of the search parameter) seems to have become so long it no longer replaces.

Here are snippets to show what I’m referring to:

$tokens = array('{%T_ID%}','{%NAV_BAR%}','{%TEAM_NAMES%}','{%CLUB_NAME%}','{%TEAM_NAME%}','{%STATE%}', '{%AGE_GROUP%}','{%LEVEL%}','{%CONTACT_NAME%}','{%CONTACT_ADDRESS%}','{%CONTACT_CITY%}','{%CONTACT_ZIP%}','{%CONTACT_EMAIL%}','{%CONTACT_PHONE_NUM%}','{%COACH_NAME%}','{%COACH_EMAIL%}','{%COACH_PHONE_NUM%}','{%SECRET_Q%}','{%SECRET_A%}','{%SO_CAL_ID%}','{%STATE_ID%}','{%NUM_PLAYERS%}','{%NOTES%}','{%SCORE_W%}','{%SCORE_L%}','{%SCORE_T%}','{%SCORE_GF%}','{%SCORE_GA%}','{%SCORE_GD%}','{%SCORE_POINTS%}');

    $replace = array(
        $tId => null,
        $navBar->Parse() => null,
        $teamNameOptions => null,
        _CLUB_NAME_ => _TEAM_TABLE_,
        _TEAM_NAME_ => _TEAM_TABLE_,
        _STATE_ => _TEAM_TABLE_,
        $ageOptions => null,
        $levelOptions => null,
        _CONTACT_NAME_ => _TEAM_TABLE_,
        _CONTACT_ADDRESS_ => _TEAM_TABLE_,
        _CITY_ => _TEAM_TABLE_,
        _ZIP_ => _TEAM_TABLE_,
        _CONTACT_EMAIL_ => _TEAM_TABLE_,
        _CONTACT_PHONE_NUM_ => _TEAM_TABLE_,
        _COACH_NAME_ => _TEAM_TABLE_,
        _COACH_EMAIL_ => _TEAM_TABLE_,
        _COACH_PHONE_NUM_ => _TEAM_TABLE_,
        _SECRET_Q_ => _TEAM_TABLE_,
        _SECRET_A_ => _TEAM_TABLE_,
        _SO_CAL_ID_ => _TEAM_TABLE_,
        _STATE_ID_ => _TEAM_TABLE_,
        _NUM_PLAYERS_ => _TEAM_TABLE_,
        _NOTES_ => _TEAM_TABLE_,
        _SCORE_W_ => _TEAM_TABLE_,
        _SCORE_L_ => _TEAM_TABLE_,
        _SCORE_T_ => _TEAM_TABLE_,
        _SCORE_GF_ => _TEAM_TABLE_,
        _SCORE_GA_ => _TEAM_TABLE_,
        _SCORE_POINTS_ => _TEAM_TABLE_
    );

Doing some extensive white-box testing the values are all there, however the very last token and replacement {%SCORE_POINTS%} is not being replaced with a number as a should be, rather null.

This:

<input type="text" name="fScorePoints" value="{%SCORE_POINTS%}">

Should become:

<input type="text" name="fScorePoints" value="5">

But actually becomes:

<input type="text" name="fScorePoints" value="">

I tested further by adding another token and replacement and that too is not properly replaced, leading me to assume there is some form of character limit?

I can confirm all other tokens and replacements work perfectly fine, just not this last one.

What’s going on?

Thanks for any insight.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:40:33+00:00Added an answer on June 9, 2026 at 4:40 pm

    From the documentation for str_replace():

    If search and replace are arrays, then str_replace() takes a value
    from each array and uses them to search and replace on subject. If
    replace has fewer values than search, then an empty string is used for
    the rest of replacement values.

    As the commenter pointed out, you have 1 less replacement value than you have subjects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on templating system. I do have input of html document from
I'm attempting to use mustache.js as a templating system for JSON data that I'm
I have a templating system I was trying to use with my Phonegap App
I have a templating system that looks similar to old-style ASP code. I run
Say I need to have a templating system where a user can edit it
I am writing a trivial templating system for running dynamic queries on a server.
I'm struggling a bit with the play 2.0 templating system; I have a method
In HTML I can build a simple templating system by providing a template in
I want to understand how to use templating system and permalinks on php websites
I have the following string in the smarty (php templating system) variable $test: <img

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.