I have an array containing much more items than just this one.
This is just an example of an item:
[0] => Array
(
[id] => 6739380664
[created_at] => 1260991464
[text] => @codeforge thx for following
[source] => web
[user] => Array
(
[id] => 90389269
[name] => Lea@JB
[screen_name] => Lea_JB
[description] => Fan of JB and Daourite singers!! (:
[location] => Germany
[url] =>
[protected] =>
[followers_count] => 33
[profile_image_url] => http://a3.01/Usher_und_JB_normal.jpg
)
[truncated] =>
[favorited] =>
[in_reply_to_status_id] =>
[in_reply_to_user_id] => 18055539
)
And I have a function
function parseLink($text)
{
$text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a href=\"\\0\">\\0</a>", $text);
return $text;
}
How can I apply my function parseLink($text) for the array item text , without having to go through an loop?
That it returns the whole array containing all all fields as it was, but with the modiefied array field
text? It’s not just the item $myarray[0]; there are more items like $myarray[1],$myarray[2] and soon.
You can accomplish this in 2 different ways:
1) You could use the return value of
parseLink()and re-assign the variable in the array:2) You can modify your
parseLink()function to accept the argument by reference which would cause it to be modified in place: